Capítulo 133 de 147

Chapter 133: Lucide Svelte

Core Idea

Svelte components for Lucide icons that work seamlessly with both Svelte 4 and Svelte 5. Each icon is a reactive Svelte component that renders as an inline SVG, providing excellent performance and integration with Svelte's reactive system and modern features.

Key Concepts

  • Use icons as Svelte components with full reactivity and TypeScript support
  • Bind icon properties to reactive variables and stores
  • Create dynamic icon systems that respond to application state
  • Build type-safe interfaces with comprehensive TypeScript definitions
  • Optimize bundle sizes with direct icon imports and tree-shaking
  • @typedef {Object} MenuItem
  • @property {string} name
  • @property {string} href

Code Examples

<script>
  import { Skull } from '@lucide/svelte';
</script>

<Skull />
  • What it demonstrates: Lucide Svelte usage pattern from the official Lucide docs.

Key Takeaways

  1. Use icons as Svelte components with full reactivity and TypeScript support
  2. Bind icon properties to reactive variables and stores
  3. Create dynamic icon systems that respond to application state
  4. Build type-safe interfaces with comprehensive TypeScript definitions
  5. Optimize bundle sizes with direct icon imports and tree-shaking

Connects To

  • Package Reference: part of the Package Reference section of the Lucide docs.
  • @lucide/icons: overview page for this section.