Icon for Astro
Astro icon rendering for Lucide symbols and Simple Icons brand marks.
The Icon component resolves Lucide and Simple Icons icons.
- Use the
Iconcomponent when an icon name comes from content, frontmatter, or project configuration. - Import
@lucide/astroorsimple-iconscomponents directly when the icon is code-owned UI.
Pass a kebab-case slug, for example map-pin. Prefix a name with lucide: or
simple: to choose one set, for example lucide:github or simple:github.
Icons are decorative by default. Pass an aria-label when the icon carries
meaning.
How a name resolves
Read name or href
A set name is the slug. With no name, a known href supplies the slug.
Choose the search order
A name searches Lucide, then Simple Icons. A link searches Simple Icons, then Lucide.
Honor a prefix
lucide: or simple: searches only that set.Render the match
The first matching icon renders. An unknown name renders no mark.
Installation
bunx --bun shadcn@latest add @gnostic/iconnpx shadcn@latest add @gnostic/iconpnpm dlx shadcn@latest add @gnostic/iconInstall component packages
bun add simple-iconsnpm install simple-iconspnpm add simple-iconsCopy the files
src/components/ui/icon/icon.astrosrc/components/ui/icon/icon-frame.astrosrc/components/ui/icon/icon-variants.tssrc/components/ui/icon/lucide-icon.tssrc/components/ui/icon/resolve-icon.tssrc/components/ui/icon/simple-icon.astrosrc/components/ui/icon/simple-icon.tssrc/components/ui/icon/types.tssrc/components/ui/icon/index.ts
Direct imports
Usage
For content-owned icons, pass plain names to Icon:
<Icon name={feature.icon} />
For UI icons that are fixed in code:
import Heart from "@lucide/astro/icons/heart"
<Heart />
For brand icons:
import Github from "simple-icons/icons/github.svg"
<Github fill="currentColor" />
Example
Add data-icon to a Lucide icon used in a control. The control can then apply its own icon alignment and size rules.
Notes
- Use plain icon names in content, frontmatter, or project configuration.
- Render content-owned icon names through
Icon. - Import icon components directly for fixed code-owned UI icons.
- Prefer
@lucide/astrofor interface icons andsimple-iconsfor brand marks when importing directly. - Named Simple Icons use path data on the server and render inline SVG. Static builds include the rendered icons without copying the full SVG set. Server builds keep the icon data for lookup at request time.
API Reference
Read the installed source for the complete prop types.
When to use Icon
Use Icon when content data supplies an icon name or brand reference. Import Lucide directly for fixed interface icons when that makes the source clearer. Keep icon use consistent within one action row.
Keyboard and behavior
Decorative icons should stay hidden from assistive technology. Name the button or link that contains an icon-only action. An unknown icon name renders no mark, so verify values that come from a CMS.
Theme and layout
Match icon size to the text and use current text color for interface symbols. Brand artwork can require its own contrast treatment in dark mode; do not rely on a low-contrast logo alone to identify a link.