<SegmentedControl.Root defaultValue="inbox">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
包含控制项。
道具 | 类型 | 默认值 |
---|---|---|
大小 | Responsive<"1" | "2" | "3"> | "2" |
变体 | "surface" | "classic" | "surface" |
半径 | "none" | "small" | "medium" | "large" | "full" | 没有默认值 |
代表控制的各个值。
使用size
道具来控制控制的大小。
<Flex align="start" direction="column" gap="4">
<SegmentedControl.Root defaultValue="inbox" size="1">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
<SegmentedControl.Root defaultValue="inbox" size="2">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
<SegmentedControl.Root defaultValue="inbox" size="3">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
</Flex>
使用variant
道具来控制控制的视觉样式。
<Flex align="start" direction="column" gap="4">
<SegmentedControl.Root defaultValue="inbox" variant="surface">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
<SegmentedControl.Root defaultValue="inbox" variant="classic">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
</Flex>
使用radius
道具来分配特定的半径值。
<Flex align="start" direction="column" gap="4">
<SegmentedControl.Root defaultValue="inbox" radius="none">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
<SegmentedControl.Root defaultValue="inbox" radius="small">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
<SegmentedControl.Root defaultValue="inbox" radius="medium">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
<SegmentedControl.Root defaultValue="inbox" radius="large">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
<SegmentedControl.Root defaultValue="inbox" radius="full">
<SegmentedControl.Item value="inbox">Inbox</SegmentedControl.Item>
<SegmentedControl.Item value="drafts">Drafts</SegmentedControl.Item>
<SegmentedControl.Item value="sent">Sent</SegmentedControl.Item>
</SegmentedControl.Root>
</Flex>