# layout.blocks

An amount shown as a row of blocks, like a battery: the more blocks filled, the more of it. Each block is a layout.blocks.cell, with data-on on the filled ones; data-tone="success", "warning" or "danger" on the row colours them by level. Give it aria-valuenow, aria-valuemin and aria-valuemax

Component: [`<Layout>`](https://www.prongs.dev/docs/components/layout.md) · Renders: `<div>` · Role: `meter` · Profile: [UI](https://www.prongs.dev/docs/intents/ui.md)

## Example

```tsx
<Layout intent="layout.blocks">
  …
</Layout>
```

## Choosing between neighbours

Find the row that describes your element, and use the intent on the right.

| If it is for… | Use |
|---|---|
| An amount shown as a row of blocks, like a battery: the more blocks filled, the more of it. Each block is a layout.blocks.cell, with data-on on the filled ones; data-tone="success", "warning" or "danger" on the row colours them by level. Give it aria-valuenow, aria-valuemin and aria-valuemax | `layout.blocks` (this page) |
| A smooth amount where small differences matter | [`layout.meter`](https://www.prongs.dev/docs/intents/layout/meter.md) |

## Connections

Declared in the registry, both directions. Where an intent is used in your own code is something check and the gallery see; this site has no app code.

- Built from: [`arrange.row`](https://www.prongs.dev/docs/intents/ui.md#arrange-row)

## For registry authors

**Starter intents.** These are the intents `prongs add` puts in your registry, shown in this site’s theme. Yours are your own `registry.ts`: rename, restyle and add to them, and see them with `prongs add gallery`.

What this intent is built from and its entry in `components/prongs/registry.ts`. You only need this to change how it looks or to add an intent like it.

How layout.blocks resolves, and its definition

Each layer adds to the one before it; a later class wins over an earlier one that sets the same thing.

- [`arrange.row`](https://www.prongs.dev/docs/intents/ui.md#arrange-row) — Children in a wrapping row

  ```
  flex flex-row flex-wrap items-center
  ```

- `layout.blocks` (this page) — An amount shown as a row of blocks, like a battery: the more blocks filled, the more of it. Each block is a layout.blocks.cell, with data-on on the filled ones; data-tone="success", "warning" or "danger" on the row colours them by level. Give it aria-valuenow, aria-valuemin and aria-valuemax

  ```
  flex-nowrap items-center gap-0.5 [&>[data-on]]:bg-foreground
  data-[tone=success]:[&>[data-on]]:bg-success
  data-[tone=warning]:[&>[data-on]]:bg-warning
  data-[tone=danger]:[&>[data-on]]:bg-destructive
  ```

Final classes

```
flex flex-row flex-nowrap items-center gap-0.5
[&>[data-on]]:bg-foreground
data-[tone=success]:[&>[data-on]]:bg-success
data-[tone=warning]:[&>[data-on]]:bg-warning
data-[tone=danger]:[&>[data-on]]:bg-destructive
```

Definition

```ts
'layout.blocks': {
  kind: 'semantic',
  description: 'An amount shown as a row of blocks, like a battery: the more blocks filled, the more of it. Each block is a layout.blocks.cell, with data-on on the filled ones; data-tone="success", "warning" or "danger" on the row colours them by level. Give it aria-valuenow, aria-valuemin and aria-valuemax',
  refs: ['arrange.row'],
  binding: {
    ariaRole: 'meter',
    classes: 'flex-nowrap items-center gap-0.5 [&>[data-on]]:bg-foreground data-[tone=success]:[&>[data-on]]:bg-success data-[tone=warning]:[&>[data-on]]:bg-warning data-[tone=danger]:[&>[data-on]]:bg-destructive',
  },
  notFor: [
    {
      context: 'a smooth amount where small differences matter',
      instead: 'layout.meter',
    },
  ],
},
```
