Icon
A Lucide icon in the system's size, colour and line weight. Inside a button, menu item or nav item a bare lucide-react icon is styled the same way.
Preview
Use
The code of the preview above
import { Icon, Row } from '@/components/ui';
import { Heart, MapPin, Search, Star } from 'lucide-react';
<Row gap={4}>
<Icon icon={Search} />
<Icon icon={MapPin} label="Location" />
<Icon icon={Star} solid label="Favourite" />
<Icon icon={Heart} size="lg" />
<Icon icon={Star} size="xl" />
</Row>Options
| Option | Type | What it does |
|---|---|---|
icon Needed | ComponentType | An icon from lucide-react: import { Search } from 'lucide-react', then <Icon icon={Search} />. |
label | string | What the icon means, when it stands alone without text. Leave out when text sits next to it. |
size | "sm" | "md" | "lg" | "xl" · default 'md' | md follows the text size; lg and xl are fixed sizes for empty states and tiles. |
solid | boolean | Filled in: the "on" state of a star, a heart, a pin. |
It also takes the 487 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
Without React
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/icons.cssHelpers: states, do and don’t
A lucide-react icon in the theme's size and weight: <Icon icon={Search} />; give label when the icon alone says something.
Hooks and functions the components are made of, passed on so a project uses the same ones: keyboard shortcuts, options loaded while typing, search matching, saved preferences, screen-reader announcements, smooth sizes, the theme.
Do
- Use
useShortcutfor app-wide keys, and show the key withformatShortcutso it reads right on each computer. - Use
announce()to tell a screen reader what changed when nothing visible takes focus ("3 results").
Don't
- Don't turn off the smooth sizes
Toasterstarts; boxes would jump when their content changes.