# GridColumnsSelect

How many products a listing shows in a row: a label and a few numbers to choose between.

Code: `components/ui/grid-columns-select.tsx`. Figma: Grid Columns Select, node 2109:1076. Live: https://design.id-hub.dk/components/grid-columns-select

```tsx
import { GridColumnsSelect } from '@/components/ui/grid-columns-select';

<GridColumnsSelect label="Kolonner" name="columns" options={[3, 4, 6]} defaultValue={3} />
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| label (required) | `string` |  | What is being chosen, such as "Kolonner". Shown before the options and read aloud as the name of the group. |
| name (required) | `string` |  | The form field name. One select is one radio group. |
| options (required) | `number[]` |  | The column counts to choose between, such as [3, 4, 6]. |
| value | `number` |  | The chosen count. With onChange the select is controlled. |
| defaultValue | `number` |  | The count chosen from the start, uncontrolled. |
| onChange | `(value: number) => void` |  | Called with the new count. |

Do:
- Offer counts the grid can hold: product overviews may use their own grid, such as six tiles per row.
- Keep the choice in the address or in a setting, so the listing comes back the same.

Do not:
- Do not use it for anything but the number of columns in a listing.
- Do not show it on a phone, where a listing has no room for a choice.

Accessibility:
- Each option is a native radio button in a fieldset named by the label: arrow keys move, a form posts the value.
- The chosen option is marked by the four corners from the logo and by the text colour.
- Figma sets an unchosen option in text/weak (Ash, about 2:1 on White). Here it is text/muted, which holds 4.5:1 in light and dark, until Peter answers question 32.

Tokens it uses:
- color.text.default
- color.text.muted
- radius.sm
- type.body.sm
- space.inline.1
- space.inline.2
- component.grid-column-option.size
- component.grid-column-option.corner-size
- component.grid-column-option.corner-inset
- component.variation-option.corner-radius

---

Drawn in Figma: one of the 8 components that may be used anywhere, the public site included. All of them: https://design.id-hub.dk/components.md. Token values: https://design.id-hub.dk/tokens.md.

Index of everything, as text: https://design.id-hub.dk/llms.txt. Never invent a colour, a size, a component or a product fact: if it is not here, it does not exist yet.
