# Components

These 8 components are drawn in Figma: Button, UtilityButton, VariationPicker, ProductVariationSelect, ProductCard, Pill, GridColumnsSelect, Icon. On the public site, in campaigns and on brand surfaces nothing else exists: there is no Card, Input, Select, Dialog, Badge or Tabs there yet. Lay out with Tailwind flex and grid utilities and the spacing tokens.
For internal ID software there are 33 more, not drawn in Figma and built only from the tokens: Stack, Grid, Heading, Text, Link, Card, CardHeader, Badge, Actions, Skeleton, PendingNote, EmptyState, StatCard, Callout, FlashMessage, Table, BarList, Pagination, Breadcrumb, Navigation, FormField, Input, Textarea, Select, Checkbox, RadioGroup, ErrorSummary, QuantityStepper, Dialog, Drawer, Tabs, CopyButton, PrintButton. They and their rules are in software.md (https://design.id-hub.dk/software.md). Use them only in the tools ID builds for itself.

## Button

The call to action. Solid for the one primary action of a view, outline for the action beside it.

Code: `components/ui/button.tsx`. Figma: CTA Button, node 25:1799. Live: https://design.id-hub.dk/components/button

```tsx
import { Button, buttonClasses } from '@/components/ui/button';

<Button>Tilføj til kurv</Button>
<Button variant="outline">Find forhandler</Button>
<Button icon="arrow-right">Se kollektionen</Button>
<a className={buttonClasses({ variant: 'outline' })} href="/kontakt">Kontakt os</a>
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| variant | `'solid' \| 'outline'` | `'solid'` | Solid is filled in the button colour of the theme. Outline is a hairline in the same colour. |
| icon | `IconName` |  | An icon beside the label, by its name in the set. It is 20 px, the line height of the label, and takes the colour of the label. |
| iconPosition | `'before' \| 'after'` | `'after'` | Where the icon sits: before or after the label. |
| ...button | `ButtonHTMLAttributes` |  | Everything a native button takes: onClick, disabled, type (defaults to "button"). |

Do:
- One solid button per view. It is the thing the page wants done.
- Write the label as the action: "Tilføj til kurv", not "OK".
- Use buttonClasses on a link when the action navigates.
- Use an icon only when it adds to the label, such as an arrow on a button that leads onward.

Do not:
- Do not colour a button with Flare. Flare is for the logo only.
- Do not set your own padding, radius or font on it.
- Do not put two solid buttons side by side.
- Do not use a button with an icon and no label. An icon alone is not a call to action.

Accessibility:
- A native button: keyboard and screen reader work without script.
- Focus shows a ring in the text colour. Figma has no focus state yet, so the ring is ours until Peter draws one.

## UtilityButton

A quiet control on glass, for navigation and tools on top of an image or a coloured ground.

Code: `components/ui/utility-button.tsx`. Figma: Utility Button, node 2125:92. Live: https://design.id-hub.dk/components/utility-button

```tsx
import { UtilityButton } from '@/components/ui/utility-button';

<UtilityButton dropdown aria-expanded={open} onClick={toggle}>Find forhandler</UtilityButton>
<UtilityButton size="sm" icon="search" iconPosition="before">Søg</UtilityButton>
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| dropdown | `boolean` | `false` | Shows the chevron that says the button opens a list. Set aria-expanded with it. |
| size | `'md' \| 'sm'` | `'md'` | Medium is 36 px high with Body/md and a 20 px icon. Small is 28 px high with Body/sm and a 16 px icon. |
| icon | `IconName` |  | An icon beside the label, by its name in the set. With dropdown it is the chevron. |
| iconPosition | `'before' \| 'after'` | `'after'` | Where the icon sits: before or after the label. |
| ...button | `ButtonHTMLAttributes` |  | Everything a native button takes. |

Do:
- Use it on an image or a coloured ground, where the glass has something to blur.
- Set data-theme="dark" on a dark ground so the text turns white.

Do not:
- Do not use it as the call to action. That is Button.
- Do not use it on a plain white page: 5 % glass on white is nearly invisible.

Accessibility:
- With dropdown, set aria-expanded so a screen reader hears whether the list is open.

## VariationPicker

One choice among a product's colours or sizes. Image options for colours, text options for sizes.

Code: `components/ui/variation-picker.tsx`. Figma: Product Variation Option, node 2100:626. Live: https://design.id-hub.dk/components/variation-picker

```tsx
import { VariationPicker } from '@/components/ui/variation-picker';

<VariationPicker
  label="Størrelse"
  name="size"
  defaultValue="M"
  options={[{ value: 'S', label: 'S' }, { value: 'M', label: 'M' }, { value: 'L', label: 'L' }]}
/>
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| label (required) | `string` |  | What is being chosen, such as "Størrelse". Read aloud, not shown. |
| name (required) | `string` |  | The form field name. One picker is one radio group. |
| options (required) | `VariationOption[]` |  | { value, label, image?, disabled? }. With image it is a colour option, without it a text option. |
| value | `string` |  | The chosen value. With onChange the picker is controlled. |
| defaultValue | `string` |  | The value chosen from the start, uncontrolled. |
| onChange | `(value: string) => void` |  | Called with the new value. |
| more | `number` |  | How many more options there are than the ones shown, such as 9 for "+9". Shown as a last tile. |
| moreHref | `string` |  | Where the tile with the rest leads, such as the full list. Without it the tile is plain text. |
| moreLabel | `(count: number) => string` |  | What the tile with the rest says to a screen reader. Danish by default. |

Do:
- Use one picker per choice: one for colour, one for size.
- Give every image option a label with the colour's name.
- Brackets, the corners from the logo, are used only here, to mark the chosen variant. Never around headlines, messages or text.
- Show the first options and the rest as "+9" with more, when a product has more colours than fit.

Do not:
- Do not use it for navigation or filters.
- Do not show a price or stock inside an option.

Accessibility:
- Each option is a native radio button in a fieldset: arrow keys move, a form posts the value.
- The chosen option is marked by four corners from the logo and by Ink text. Figma draws Default and Selected; the hover ground is ours until Peter draws one.
- Figma sets an unchosen option's text in text/weak (Ash, about 2:1 on White). Here it stays Stone, which holds 4.5:1, until Peter answers the question on the variant selector in docs/SPOERGSMAAL-TIL-PETER.md.
- The tile with the rest reads as "9 flere", not as "+9", and is a link when it leads somewhere.

## ProductVariationSelect

One choice on a product page with its name shown: a hairline, the label, and the options of the variant selector.

Code: `components/ui/product-variation-select.tsx`. Figma: Product Variation Select, node 2100:689. Live: https://design.id-hub.dk/components/product-variation-select

```tsx
import { ProductVariationSelect } from '@/components/ui/product-variation-select';

<ProductVariationSelect
  label="Størrelse"
  name="size"
  defaultValue="L"
  options={[{ value: 'S', label: 'S' }, { value: 'M', label: 'M' }, { value: 'L', label: 'L' }]}
  more={9}
/>
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| label (required) | `string` |  | What is being chosen, such as "Størrelse". Shown above the options and read aloud as the name of the group. |
| ...picker | `VariationPickerProps` |  | Everything VariationPicker takes: name, options, value, defaultValue, onChange, more, moreHref, moreLabel. |

Do:
- Use one per choice on a product page: one for colour, one for size.
- Stack them; each brings its own hairline.

Do not:
- Do not use it in a listing or a card. There the options stand alone, as VariationPicker.
- Do not add a second label above it.

Accessibility:
- The label is shown once for the eye and read once as the name of the radio group.
- Everything else is VariationPicker: native radio buttons, arrow keys, a form post.

## ProductCard

One product in a listing: the packshot on Snow with the article number and the name, and on hover or focus the colours and the price.

Code: `components/ui/product-card.tsx`. Figma: Product Card, node 25:2701. Live: https://design.id-hub.dk/components/product-card

```tsx
import { ProductCard } from '@/components/ui/product-card';

<ProductCard
  href="/produkter/0510"
  sku="0510"
  name="T-TIME® T-shirt"
  image={packshot}
  price="kr. 99,00"
  priceNote="(kr. 79,20 ex. moms)"
  swatches={colours}
  moreColours={13}
  pills={<Pill size="sm">Økologisk</Pill>}
/>
<ProductCard breakpoint="mobile" href="/produkter/0510" sku="0510" name="T-TIME® T-shirt" image={packshot} price="kr. 99,00" />
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| href (required) | `string` |  | Where the card leads. The whole card is the link. |
| sku (required) | `string` |  | The article number, such as "0510". |
| name (required) | `string` |  | The product name. |
| image (required) | `string` |  | The packshot. Shown on Snow, multiplied, never cropped. |
| price | `string` |  | Already formatted, such as "kr. 99,00". Never computed in the card. |
| priceNote | `string` |  | Already formatted, such as "(kr. 79,20 ex. moms)". |
| swatches | `ProductCardSwatch[]` |  | { label, image } for the colours shown. |
| moreColours | `number` |  | How many more colours there are, shown as +13. |
| pills | `ReactNode` |  | Pills in the top corner of the image, such as <Pill>Økologisk</Pill>. |
| breakpoint | `'default' \| 'mobile'` | `'default'` | Default is the card for a pointer. Mobile is the card for a phone: the name and the price stand under the image, always, and there are no colours. |
| expanded | `'hover' \| 'always'` | `'hover'` | On the default card: hover shows price and colours on pointer hover and keyboard focus, as in Figma. Always keeps the panel open. |
| labels | `{ colours?: (count: number) => string }` |  | Texts read aloud. Pass translations here. |

Do:
- Lay cards out in a grid with the seam (2 px) between them: they are tiles of one block.
- Pass the price as the shop formats it. The card never calculates.
- Use breakpoint="mobile" on a phone, where there is no hover.
- Put a pill on the image only for a fact from the product data.

Do not:
- Do not put a packshot on any ground but Snow.
- Do not crop the packshot or give it a shadow.
- Do not invent a price, a name or an article number for a card.

Accessibility:
- The name is the link and covers the whole card.
- The price and the number of colours are read aloud once, also when the panel is closed.
- The article number is Charcoal on Snow, 6.58:1.

## Pill

A short label on the base surface, such as "Økologisk" on a product image.

Code: `components/ui/pill.tsx`. Figma: Pill, node 2124:1130. Live: https://design.id-hub.dk/components/pill

```tsx
import { Pill } from '@/components/ui/pill';

<Pill>Økologisk</Pill>
<Pill size="sm">Økologisk</Pill>
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| size | `'md' \| 'sm'` | `'md'` | Medium is 28 px high with Body/md. Small is 22 px high with Body/sm. |
| children (required) | `ReactNode` |  | The label. A word or two. |

Do:
- Use it on a product image or a coloured ground, where the white of the pill stands out.
- Keep the label to a word or two.
- Pass it to ProductCard with the pills prop.

Do not:
- Do not invent the fact on a pill. "Økologisk" comes from the product data, with the certificate behind it.
- Do not use it as a button or a filter. It does nothing when pressed.
- Do not colour it. It is the base surface with the text colour.

Accessibility:
- Plain text: a screen reader reads the label where it stands.
- On a white page a pill has no edge. Put it on an image or a ground.

## 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.

## Icon

An icon from the Figma set, treated as part of the text and drawn in the text colour. Next to running text it is 1.5 times the text size; inside a control it takes one of four sizes.

Code: `components/ui/icon.tsx`. Figma: Icon, node 2173:116. Live: https://design.id-hub.dk/components/icon

```tsx
import { Icon } from '@/components/ui/icon';

<Icon name="search" />
<button aria-label="Luk"><Icon name="x" size="md" /></button>
<Icon name="check" label="På lager" />
```

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| name (required) | `IconName` |  | One of the icons in icons/icons.json. The set is closed. |
| label | `string` |  | What the icon says when it stands alone. Without it the icon is hidden from screen readers. |
| size | `'sm' \| 'md' \| 'lg' \| 'xl'` |  | 16, 20, 24 or 36 px. Leave it out next to running text: the icon is then 1.5 times the text size, on the 4 px grid. Set it inside a control, where the icon matches the line height of its text: md beside Body/md and Button/md, sm beside Body/sm. |

Do:
- Next to running text, set the size by the text size around the icon.
- Inside a control, such as a button, give the icon the size that matches the line height of its text.
- Add a new icon in Figma first, then export it to icons/svg and add it to icons/icons.json.

Do not:
- Do not paste an svg into a page. Use the name.
- Do not use filled icons or icons from another set.
- Do not scale an icon with a transform or set its stroke yourself. The stroke follows the size: (size + 16) / 24.
- Do not let an icon be the only carrier of meaning: status has text beside it.

Accessibility:
- Decorative by default. With label it is announced as an image with that name.

## Icons

<Icon name="..." /> takes one of these 21 names. The set is closed.

| Name | Means |
| --- | --- |
| composition | Materialets sammensætning, fx 100 % bomuld |
| fit | Pasform |
| weight | Stofvægt, fx 175 g/m² |
| search | Søg |
| user | Konto, log ind |
| heart | Favorit |
| size | Størrelse, størrelsesguide |
| filter | Filtrér en liste |
| menu | Åbn menuen |
| arrow-right | Videre, gå til |
| arrow-left | Tilbage |
| arrow-up | Op, til toppen |
| arrow-down | Ned, hent |
| chevron-left | Forrige |
| chevron-right | Næste, fold ud til siden |
| chevron-up | Fold sammen |
| chevron-down | Fold ud, åbn en liste |
| refresh | Opdatér, prøv igen |
| check | Valgt, gennemført |
| plus | Tilføj, flere |
| x | Luk, fjern |
