样式化的徽章元素。
<Flex gap="2">
<Badge color="orange">In progress</Badge>
<Badge color="blue">In review</Badge>
<Badge color="green">Complete</Badge>
</Flex>
此组件基于 span
元素,并支持通用 margin 属性。
属性 | 类型 | 默认值 |
---|---|---|
asChild | boolean | 无默认值 |
size | Responsive<"1" | "2" | "3"> | "1" |
variant | "solid" | "soft" | "surface" | "outline" | "soft" |
color | enum | 无默认值 |
highContrast | boolean | 无默认值 |
radius | "none" | "small" | "medium" | "large" | "full" | 无默认值 |
使用 size
属性来控制尺寸。
<Flex align="center" gap="2">
<Badge size="1" color="indigo">
New
</Badge>
<Badge size="2" color="indigo">
New
</Badge>
<Badge size="3" color="indigo">
New
</Badge>
</Flex>
使用 variant
属性来控制视觉样式。
<Flex gap="2">
<Badge variant="solid" color="indigo">
New
</Badge>
<Badge variant="soft" color="indigo">
New
</Badge>
<Badge variant="surface" color="indigo">
New
</Badge>
<Badge variant="outline" color="indigo">
New
</Badge>
</Flex>
使用 color
属性来分配特定的颜色。
<Flex gap="2">
<Badge color="indigo">New</Badge>
<Badge color="cyan">New</Badge>
<Badge color="orange">New</Badge>
<Badge color="crimson">New</Badge>
</Flex>
使用 highContrast
属性来增加与背景的颜色对比度。
<Flex direction="column" gap="2">
<Flex gap="2">
<Badge color="gray" variant="solid">
New
</Badge>
<Badge color="gray" variant="soft">
New
</Badge>
<Badge color="gray" variant="surface">
New
</Badge>
<Badge color="gray" variant="outline">
New
</Badge>
</Flex>
<Flex gap="2">
<Badge color="gray" variant="solid" highContrast>
New
</Badge>
<Badge color="gray" variant="soft" highContrast>
New
</Badge>
<Badge color="gray" variant="surface" highContrast>
New
</Badge>
<Badge color="gray" variant="outline" highContrast>
New
</Badge>
</Flex>
</Flex>
使用 radius
属性来分配特定的圆角值。
<Flex gap="2">
<Badge variant="solid" radius="none" color="indigo">
New
</Badge>
<Badge variant="solid" radius="large" color="indigo">
New
</Badge>
<Badge variant="solid" radius="full" color="indigo">
New
</Badge>
</Flex>