组件

无线电卡片

一组交互式卡片,一次只能选择一个。

<Box maxWidth="600px">
<RadioCards.Root defaultValue="1" columns={{ initial: '1', sm: '3' }}>
<RadioCards.Item value="1">
<Flex direction="column" width="100%">
<Text weight="bold">8-core CPU</Text>
<Text>32 GB RAM</Text>
</Flex>
</RadioCards.Item>
<RadioCards.Item value="2">
<Flex direction="column" width="100%">
<Text weight="bold">6-core CPU</Text>
<Text>24 GB RAM</Text>
</Flex>
</RadioCards.Item>
<RadioCards.Item value="3">
<Flex direction="column" width="100%">
<Text weight="bold">4-core CPU</Text>
<Text>16 GB RAM</Text>
</Flex>
</RadioCards.Item>
</RadioCards.Root>
</Box>

API 参考

此组件继承了来自 单选组基本组件 的 props,并支持 常见的边距 props

属性类型默认值
asChild
布尔值
无默认值
size
响应式<"1" | "2" | "3">
"2"
variant
"surface" | "classic"
"surface"
color
枚举
无默认值
highContrast
布尔值
无默认值
columns
响应式<枚举 | 字符串>
"repeat(auto-fit, minmax(160px, 1fr))"
gap
响应式<枚举 | 字符串>
"4"

项目

组中可以被选中的一个项目。

示例

尺寸

使用 size 属性控制尺寸。

<Flex align="center" gap="3">
<RadioCards.Root size="1">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root size="2">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root size="3">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
</Flex>

变体

使用 variant 属性控制视觉样式。

<Flex direction="column" gap="3" maxWidth="200px">
<RadioCards.Root variant="surface">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root variant="classic">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
</Flex>

颜色

使用 color 属性分配特定的 颜色

<Flex direction="column" gap="3" maxWidth="200px">
<RadioCards.Root defaultValue="1" color="indigo">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="cyan">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="orange">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="crimson">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
</Flex>

高对比度

使用 highContrast 属性增加与背景的颜色对比度。

<Grid columns="2" gap="3" display="inline-grid">
<RadioCards.Root defaultValue="1" color="indigo">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="indigo" highContrast>
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="cyan">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="cyan" highContrast>
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="orange">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="orange" highContrast>
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="crimson">
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root defaultValue="1" color="crimson" highContrast>
<RadioCards.Item value="1">8-core CPU</RadioCards.Item>
</RadioCards.Root>
</Grid>

禁用

<Flex direction="column" gap="4" maxWidth="450px">
<RadioCards.Root columns="2" defaultValue="2">
<RadioCards.Item value="1">Off</RadioCards.Item>
<RadioCards.Item value="2">On</RadioCards.Item>
</RadioCards.Root>
<RadioCards.Root columns="2" defaultValue="2">
<RadioCards.Item value="1" disabled>
Off
</RadioCards.Item>
<RadioCards.Item value="2" disabled>
On
</RadioCards.Item>
</RadioCards.Root>
</Flex>
上一个单选组
下一个滚动区域