# Icons

Dynamic UI renders Lucide icons by name. Exact props: `widgets-get-component-props` (`DIcon`).

---

## Names: Lucide in PascalCase

Every `icon`, `iconStart` and `iconEnd` prop takes the Lucide icon name in **PascalCase**: `ArrowLeft`, `CreditCard`, `Search`, `Plus`, `Trash2`. Kebab-case (`arrow-left`) or lowercase (`search`) names do not render.

Browse names at https://lucide.dev/icons/ and convert them to PascalCase (`credit-card` → `CreditCard`).

## DIcon

```tsx
<DIcon icon="Wallet" color="primary" size="2rem" hasCircle />
```

| Prop | Use |
|------|-----|
| `icon` | Required. The name |
| `color` | Semantic color (`primary`, `danger`, …). Use `color`, not a `text-*` class |
| `size` | A CSS size (`1.5rem`), or a responsive map by breakpoint |
| `hasCircle` | Draws the icon inside a circle |
| `strokeWidth` | Line width |
| `ariaHidden`, `ariaLabel` | Accessibility (below) |

## Accessibility

`DIcon` is **hidden from screen readers by default** (`ariaHidden` defaults to `true`), because an icon is usually decorative: it sits next to a visible label or inside a control that has its own name.

- An icon that carries meaning on its own (a status with no text next to it): give it `ariaLabel`.
- An icon-only button: use `DButtonIcon` plus `aria-label` (`modyo://docs/widgets/components-buttons`).
- Inputs with a clickable icon: `iconStartAriaLabel` / `iconEndAriaLabel` name it.

## Icons in the build

The canonical template's build includes only the Lucide icons the widget uses (the `lucideSubset` plugin in `vite.config.ts`):

- names that appear as string literals anywhere in `src/` (attributes, arrays, constant maps, `enum` values, default props);
- the icons Dynamic UI uses internally;
- the names listed in the plugin's `include` option.

In `npm run dev` every icon is available; in a build, a name that never appears as a literal is missing, and the icon renders nothing without an error. For names computed at runtime, declare the possible names in a constant in `src/` or add them to `include`. After a build, `node_modules/.vite/icons-manifest.json` lists the included names.

---

## Common mistakes

| Wrong | Right |
|-------|-------|
| `icon="credit-card"`, `icon="inbox"` | `icon="CreditCard"`, `icon="Inbox"` |
| `<DIcon theme="success">` | `<DIcon color="success">` |
| `<DIcon className="text-primary">` | `<DIcon color="primary">` |
| A meaningful icon without a name | `ariaLabel` on the icon, or visible text next to it |
| An icon name read from an API, not declared anywhere | Declare the possible names in `src/`, or add them to `include` |
