Icons
Components draw their icons with lucide-react, imported by name the way shadcn does. Icon names one for screen readers when it carries meaning.
Install
Every item that shows an icon lists lucide-react as a dependency, without a version, so shadcn installs the latest release in a project that doesn't have it and leaves the one you have alone. The icons need 1.68.0 or newer: upgrade an older one. Add it yourself to use icons in your own code, and add icon for named icons:
Import by name
Import each icon by its name from lucide-react; your bundler keeps only the ones you use. Browse the whole set on lucide.dev.
The icons the registry uses
Pick one to see its import, ready to copy.
Decorative or meaningful
- Lucide sets
aria-hiddenon an icon that has noaria-*,roleortitleprop, so a decorative icon next to text needs nothing. It is hidden from agents too. - When the icon is the only sign of what it means, wrap it:
<Icon icon={XIcon} label="…" />rendersrole="img"with thataria-label, in the page's language. - An icon-only button is named by the button (
aria-label), and its icon stays decorative.
Size
Controls size their icons: Button, Toggle, menu items, inputs and selects set [&_svg]:size-4, Badge size-3. Those classes win over lucide's size prop. Anywhere else, give the icon a size-* class that matches the text beside it; an icon nothing sizes is 24px.
| Class | Beside | Looks |
|---|---|---|
size-3.5 | text-caption, text-body-sm | 2 min ago |
size-4 | text-body | report.pdf |
size-5 | text-title-sm, text-title | This week |
Keep lucide's stroke of 2. A tick inside a small indicator (Checkbox, Select) takes strokeWidth={2.5} or {3} to stay legible. Mirror icons that point a direction with rtl:-scale-x-100.
Colour
Icons stroke with currentColor, so a text colour colours them. For status, use the tone's text colour, and still say the status in words.
text-muted-foregroundtext-infotext-successtext-warningtext-destructive
In components
Put the icon first in a Button or Badge, before the text; the component spaces and sizes it. An Alert takes an icon as its first child and colours it with its tone. Toasts draw their tone's icon on their own.
Swap the icon library
The components import icons by name from lucide-react and nothing else depends on the library: only the import lines change. Point them at a module that exports the same names from another set, or your own drawings, and Icon takes any SVG component.
Add your own icon
Draw it to lucide's grid so it sits with the rest: a 24×24 view box, a 2px stroke with round caps and joins, fill="none" and currentColor, decorative by default, passing its props to the <svg>. In the registry and on this site, the eskais/no-inline-icons lint rule flags any <svg>; only drawings that aren't icons, like the spinner or a logo, disable it with a reason.