SunUI 图标
用同一套标准画出来的图标。
像素、双色、线性三套,同一套标准。全部会动,一行命令装好一套。
$ 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 hairline 一致。超过 32px 时降到 1.25。
只有一处强调
每个图标最多标记一个强调部位。设置变量之前,它跟随文字颜色。
物件本来的样子
优惠券留着缺口、小票留着撕边,因为 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} />