自定义内容
content 也可以传入元素,例如一个图标。此时应当通过 label 提供无障碍名称。
import { Bookmark, Check } from 'lucide-react'
import { Badge, IconButton } from '@hina-ui/react'
export default function Demo() {
return (
<Badge content={<Check className="size-3" />} tone="success" size="md" label="已完成">
<IconButton label="收藏" variant="soft">
<Bookmark />
</IconButton>
</Badge>
)
}
tsx
设置 bare 后徽标不绘制底色,也没有内边距,只负责定位与描边,尺寸由 content 决定。把 Indicator 传给 content 即可在头像角上显示状态点。
import { Avatar, Badge, Indicator, Inline } from '@hina-ui/react'
export default function Demo() {
return (
<Inline gap="lg">
<Badge
content={<Indicator tone="success" size="lg" />}
bare
label="在线"
placement="bottom-end"
shape="circle"
>
<Avatar src="/avatars/paper.webp" alt="星见书音" />
</Badge>
<Badge
content={<Indicator tone="warning" size="lg" />}
bare
label="离开"
placement="bottom-end"
shape="circle"
>
<Avatar name="星见书音" />
</Badge>
</Inline>
)
}
tsx