# Icon

Draws any Lucide icon by name, sized and colored with theme tokens.

- Family: display
- Import: `import { Icon } from "@senvenli/react/display";`
- Page: https://design.senvenli.com/docs/components/icon
- JSON: https://design.senvenli.com/docs/components/icon.json

## Example: Beside text

Next to a label the icon is decorative and takes the text color.

```tsx
import { Icon, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-300">
      <Stack direction="horizontal" space="space-075">
        <Icon name="truck" />
        <Text>Shipped</Text>
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Icon name="calendar" />
        <Text>Due April 17</Text>
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Icon name="user" />
        <Text>Ada Lovelace</Text>
      </Stack>
    </Stack>
  );
}
```

## Examples

### Sizes

Small at 12px, default at 16px and large at 20px.

```tsx
import { Icon } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-200">
      <Icon name="package" size="small" />
      <Icon name="package" />
      <Icon name="package" size="large" />
    </Stack>
  );
}
```

### Semantic colors

Only when the icon carries that meaning, and always with the word.

```tsx
import { Icon, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-300">
      <Stack direction="horizontal" space="space-075">
        <Icon name="circle-check" color="success" />
        <Text>Payment received</Text>
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Icon name="triangle-alert" color="warning" />
        <Text>Payment pending</Text>
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Icon name="circle-x" color="danger" />
        <Text>Payment failed</Text>
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Icon name="info" color="information" />
        <Text>Refund requested</Text>
      </Stack>
    </Stack>
  );
}
```

### Standing alone

Without text beside it, `label` gives the icon its accessible name.

```tsx
import { Icon, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-075">
      <Text>Project Atlas</Text>
      <Icon name="lock" color="subtle" label="Private project" />
    </Stack>
  );
}
```

## Guidelines

### When to use it

- A symbol helps people scan or recognize an action, status or object.
- An icon-only control needs a picture; give it a label.

### Use something else when

- [badge](https://design.senvenli.com/docs/components/badge.md): The status needs a word, not only a symbol.

### Do and avoid

- Pair icons with text unless the meaning is universal; give a standalone icon a label.
- Use the semantic colors (danger, success…) only when the icon carries that meaning.

## Accessibility

Built in:

- Decorative (hidden from assistive technology) when it has no label.
- Exposed as an image named by `label` when it has one.
- Directional icons mirror on right-to-left pages.

You provide:

- A `label` when the icon carries meaning on its own.

## API reference

### Icon

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| name | `IconName` |  | yes | Any Lucide name, kebab-case ("house", "search", "calendar-range"). |
| size | `IconSize` |  | no | `small` 12px, `default` 16px, `large` 20px (`ds-size-icon-*`). |
| color | `IconColor` |  | no | `inherit` (default) takes the text colour around it; the others are the `ds-icon-*` tokens. |
| label | `string` |  | no | The accessible name for an icon that carries meaning on its own. Without it the icon is decorative and hidden from assistive technology, which is right when text next to it already says the same thing. |
| isDirectional | `boolean` |  | no | Mirrors the icon on an RTL page. Left out, the names in `DIRECTIONAL_ICONS` (arrows and chevrons that point along the reading direction, undo/redo, send, sign in/out) mirror and every other icon stays as drawn. `true` mirrors any icon; `false` keeps a directional one as drawn (a compass arrow, a "swipe left" hint). |

### Tokens it reads

`--ds-icon`, `--ds-icon-brand`, `--ds-icon-danger`, `--ds-icon-information`, `--ds-icon-subtle`, `--ds-icon-success`, `--ds-icon-warning`, `--ds-size-icon`, `--ds-size-icon-large`, `--ds-size-icon-small`

## Related

- [badge](https://design.senvenli.com/docs/components/badge.md)
