外观
RadioGroup 单选组
同时展示若干互斥选项,用户选择一个值,其余选项保持可见。
import { SRadioGroup } from '@icecreamqaq/shadcn/radio-group'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SRadioGroup.v-model | AcceptableValue | 绑定选中项的值。 |
SRadioGroupItem.value | AcceptableValue | 每个选项都需要能够与其他项区分的值。 |
SRadioGroup.orientation | "horizontal" | "vertical" | 指定组的方向,配合键盘方向键导航。 |
SRadioGroup.loop | boolean | 默认 true,键盘焦点可以从末项回到首项。 |
完整 API
RadioGroup16 个成员
属性
| 名称 | 类型 |
|---|---|
modelValue | AcceptableValue |
defaultValue | AcceptableValue |
disabled | boolean |
orientation | DataOrientation |
dir | Direction |
loop | boolean |
asChild | boolean |
as | AsTag | Component |
name | string |
required | boolean |
options | readonly CollectionItem<string | number>[] |
renderLabel | RenderContent<{ item: CollectionItem<string | number>; }> |
class | ClassValue |
事件
| 名称 | 类型 |
|---|---|
update:modelValue | ((payload: AcceptableValue) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { modelValue: AcceptableValue | undefined; }) => any) |
label | ((props: { item: CollectionItem<string | number>; }) => any) |
RadioGroupItem9 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
disabled | boolean |
name | string |
required | boolean |
value | AcceptableValue |
id | string |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-radio-group>。
组件 SRadioGroup、SRadioGroupItem