Skip to content

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.

<!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>

Inline with CSS helper class ​

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

.lucide-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}