Files
lucide/docs/guide/static/svg-sprite.md
T
Eric FennisandClaude Opus 5.5 5fc65e1f1d fix(lucide-static): add icon aliases to the SVG sprite (#5200)
* docs(static): remove broken <img> sprite fragment example

Symbols in the sprite only render through <use>, so sprite.svg#name in
an <img> tag shows nothing. Point readers to the per-icon SVG files for
<img> usage instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9u8FfpNbRB7XQ9kggfSA1

* feat(lucide-static): add icon aliases to the SVG sprite

Aliases were only written as separate SVG files, so `<use href="#home" />`
did not work with the sprite. Each alias is now added as a symbol that
references the original icon's symbol with a nested `<use>`, instead of
duplicating its elements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9u8FgapYRzb6uRJnZpW7N

* Adjusted documentation

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-16 10:25:14 +01:00

2.4 KiB

description
description
Learn how to use SVG sprites with Lucide icons in your project, including basic usage and inline options.
<script setup> import Sandpack from '~/.vitepress/theme/components/editors/Sandpack.vue' </script>

Using the SVG sprite

Learn how to use SVG sprites with Lucide icons in your project, including basic usage and inline options.

The sprite is used inline: you put it in your page and reference icons with the <use> element. You may also need an additional SVG loader to handle node_modules imports in your project. Check out our codesandbox example for a working example.

To use the sprite, add it inline and reference icons with <use>, as shown below.

Inline usage

You can also use the sprite inline with the <use> element. This allows you to apply CSS styles directly to the SVG elements.

::: sandpack {template=vanilla showTabs=false editorHeight=480 editorWidthPercentage=60 dependencies="lucide-static"}

<!DOCTYPE html>
<html>
  <body>
    <svg
      width="24"
      height="24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <use href="#alarm-clock-check" />
    </svg>

    <div id="sprite" style="display: none;"></div>

    <script src="index.js"></script>
  </body>
</html>
import "./styles.css";
import sprite from "lucide-static/sprite.svg";

document.getElementById('sprite').innerHTML = sprite;

:::

Inline with CSS helper class

If you'd prefer, you can use CSS to hold your base SVG properties:

::: sandpack {template=vanilla editorHeight=320 editorWidthPercentage=60 dependencies="lucide-static"}

.lucide-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
<!DOCTYPE html>
<html>
  <body>
    <svg
      xmlns="http://www.w3.org/2000/svg"
      class="lucide-icon"
    >
      <use href="#alarm-clock-check" />
    </svg>

    <div id="sprite" style="display: none;"></div>

    <script src="index.js"></script>
  </body>
</html>
import "./styles.css";
import "./icon.css";
import sprite from "lucide-static/sprite.svg";

document.getElementById('sprite').innerHTML = sprite;

:::