Icon
A flexible icon component that wraps Lucide icons and supports custom SVG icons with standardized sizing and styling.
Examples
How to use
Use the name prop to specify the icon, and use class for custom styling.
Basic usage
astro
---
import Icon from '@/components/general/Icon.astro';
---
<Icon name="Star" /> Styled
astro
---
import Icon from '@/components/general/Icon.astro';
---
<Icon name="CircleAlert" class="w-8 h-8 text-red-500" /> Two-tone and colorful
Specify colors using utility classes to render colorful icons.
astro
---
import Icon from '@/components/general/Icon.astro';
---
<Icon name="Smile" class="w-8 h-8 text-blue-500" />
<Icon name="Heart" class="w-8 h-8 text-red-500" />
<Icon name="CircleCheck" class="w-8 h-8 text-green-500" /> Custom icon
Use custom SVG icons by placing them in the public/icons directory.
astro
---
import Icon from '@/components/general/Icon.astro';
---
<Icon name="astro.svg" size="32" /> API Reference
| Property | Description | Type | Default |
|---|---|---|---|
| name | Name of the Lucide icon or custom SVG file name (e.g., custom.svg) | string | - |
| size | The size of the icon (width and height) | number | string | 24 |
| color | Color of the icon (usually currentColor) | string | 'currentColor' |
| strokeWidth | Stroke width of the icon (for Lucide icons) | number | string | 2 |
| class | Additional CSS classes for custom styling | string | - |