Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

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 Icon component when an icon name comes from content, frontmatter, or project configuration.
  • Import @lucide/astro or simple-icons components 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/icon

Direct imports

GitHub

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/astro for interface icons and simple-icons for 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.