Icon
Lucideアイコンをラップし、標準化されたサイズとスタイリングでカスタムSVGアイコンをサポートする柔軟なアイコンコンポーネント。
例
使い方
アイコンを指定するにはnameプロパティを使用し、カスタムスタイリングにはclassを使用します。
基本的な使い方
astro
---
import Icon from '@/components/general/Icon.astro';
---
<Icon name="Star" /> スタイル付き
astro
---
import Icon from '@/components/general/Icon.astro';
---
<Icon name="CircleAlert" class="w-8 h-8 text-red-500" /> ツートーンとカラフル
ユーティリティクラスを使用して色を指定し、カラフルなアイコンをレンダリングします。
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" /> カスタムアイコン
カスタムSVGアイコンを使用するには、public/iconsディレクトリに配置します。
astro
---
import Icon from '@/components/general/Icon.astro';
---
<Icon name="astro.svg" size="32" /> APIリファレンス
| プロパティ | 説明 | タイプ | デフォルト |
|---|---|---|---|
| name | Lucideアイコンの名前またはカスタムSVGファイル名(例:custom.svg) | string | - |
| size | アイコンのサイズ(幅と高さ) | number | string | 24 |
| color | アイコンの色(通常はcurrentColor) | string | 'currentColor' |
| strokeWidth | アイコンのストローク幅(Lucideアイコン用) | number | string | 2 |
| class | カスタムスタイリングのための追加のCSSクラス | string | - |