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

Tokens it uses:
- icon.scale
- icon.size.sm
- icon.size.md
- icon.size.lg
- icon.size.xl
- icon.stroke.sm
- icon.stroke.md
- icon.stroke.lg
- icon.stroke.xl
- icon.color
- space.inline.1
- space.inline.4
- component.icon.grid

---

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.
