SunUI Icons
ひとつの基準で描いたアイコン。
ピクセル、2色、線の3セットを、ひとつの基準で。すべて動き、コマンド1行で1セット入ります。
$ npx shadcn@latest add https://sunui.synvize.com/r/icons/sunui-animated-pixel-icons.json$ npx shadcn@latest add https://sunui.synvize.com/r/icons/sunui-animated-twotone-icons.json$ npx shadcn@latest add https://sunui.synvize.com/r/icons/sunui-animated-icons.json24px グリッド、余白 2px
図形は 3 から 21 の範囲に収まります。円は中心から 8.5、正方形は 7。
線幅 1.5、丸い線端
24px で SunUI の面の 1px の境界線と揃います。32px を超えたら 1.25 に。
アクセントは一か所だけ
アクセントにするのは各アイコン最大 1 パーツ。変数を設定するまでは文字の色に従います。
品物そのままの形
クーポンには切り欠き、レシートには切り口を残します。16px で見分けるための手がかりで、飾りではありません。
意味のある動き
ベルは揺れ、カートは前に進み、チェックは描かれます。ホバー、フォーカス、状態変化のときだけ。
使い方
アイコンは currentColor を継承し、title を渡さない限りスクリーンリーダーからは隠されます。
example.tsx
import { Icon } from "@/components/ui/sunui-icons";
// Decorative, next to a text label
<button><Icon name="cart" size={16} /> Add to cart</button>
// Standalone, announced as "Claimed"
<Icon name="stamp-check" title="Claimed" />
// Point the accent part at your theme color for one subtree
<div className="[--sunui-icon-accent:var(--primary)]">
<Icon name="punch-card" />
</div>アニメーションアイコン
AnimatedIcon は同じ図形を使います。ホバー型は親のボタンがホバーまたはフォーカスされると再生され、コントロール全体がトリガーになります。トグル型は active に従い、ローディング型は true の間だけループします。視差効果を減らす設定では、どのアイコンも最終状態にすぐ切り替わります。
animated.tsx
import { AnimatedIcon } from "@/components/ui/sunui-animated-icons";
// Plays the tear along the perforation when the button is hovered
<button><AnimatedIcon name="coupon" size={16} /> Claim coupon</button>
// Menu morphs into a close icon
<button aria-expanded={open} onClick={() => setOpen(!open)}>
<AnimatedIcon name="menu" active={open} title={open ? "Close menu" : "Open menu"} />
</button>
// Fills with a short press
<AnimatedIcon name="heart" active={saved} />
// Spins only while loading
<AnimatedIcon name="loader" active={pending} />