Skip to content

Add slot support for icons

Compare
Choose a tag to compare
@ericfennis ericfennis released this 22 Feb 08:19
4ededad

New Package 📦

Lucide is now supported in Svelte with new package lucide-svelte.

Code improvements ⚡

Slots are now supported in lucide-react, lucide-vue, lucide-vue-next, lucide-preact, lucide-svelte.
Now you can pass children to Icon components. This can help improving accessibility or make it possible to render custom SVGElements over the icon.

Examples

Rendering title and description

This also improves accessibility, and enables the browser native tooltip.

<Icon>
  <title>My awesome text</title>
  <desc>More detailed description about the icon</desc>
</Icon>

Rendering for example a visual text SVGElement over the icon, for example render a ShoppingCart with a number.

With this you can now render custom elements inside Lucide icons, enables you to

<ShoppingCart>
  <text>5</text>
</ShoppingCart>

See codesandbox