Skip to content

Icon Sprite

Renders the Lucide icon sprite as hidden <symbol> definitions. Include it once per page, wherever global.css is imported (typically the site’s root layout); every Icon on the page then resolves against it.

None: it takes no props.

---
import IconSprite from '@samla/ui/IconSprite.astro';
import '@samla/ui/global.css';
import Usage from "../../../components/Usage.astro";
---
<IconSprite />

No preview here: this component renders nothing visible by design. See Icon for a live example, which only renders correctly because this docs site includes IconSprite once, site-wide.

The sprite ships a curated subset of Lucide, not the whole set. To add one:

  1. npm install lucide-static (anywhere; it’s only used as a source of SVG files, not a runtime dependency of this library).
  2. Find the icon at node_modules/lucide-static/icons/<name>.svg. Names are kebab-case and match lucide.dev/icons.
  3. Copy its <path>/<circle>/etc. children into a new <symbol id="lucide-<name>" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> block in src/elements/IconSprite.astro, keeping those five attributes (every Lucide icon shares them).
  4. Use it as <Icon name="<name>" />.