组件
单选组 Radio Group
RadioGroup:单选组。圆形选项在选中后用 primary 墨色平铺填充,中心圆点保留纸色。部件:Root、Label、Item、ItemText、ItemControl、Indicator、ItemHiddenInput。
#基础用法
Ground
<script setup lang="ts">
import { RadioGroup } from "@bysages/vue";
const papers = [
{ value: "xuan", label: "Xuan paper" },
{ value: "silk", label: "Silk" },
{ value: "bamboo", label: "Bamboo slips" },
];
</script>
<template>
<RadioGroup.Root default-value="xuan">
<RadioGroup.Label>Ground</RadioGroup.Label>
<RadioGroup.Item v-for="p in papers" :key="p.value" :value="p.value">
<RadioGroup.ItemControl />
<RadioGroup.ItemText>{{ p.label }}</RadioGroup.ItemText>
<RadioGroup.ItemHiddenInput />
</RadioGroup.Item>
</RadioGroup.Root>
</template>
#属性
#Indicator
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#ItemContext
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#ItemControl
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#ItemHiddenInput
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#ItemText
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#Item
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
disabled | boolean | undefined | — | |
invalid | boolean | undefined | — | |
value | string | — |
#Label
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#Root
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
size | String as PropType<"sm" | "md" | "lg"> | "md" | 单选刻度盘的尺寸档位,选中的圆点随之变化 |
defaultValue | string | null | 渲染时选中单选项的初始值;不需要控制单选组值时使用 | |
disabled | boolean | 为 true 时禁用单选组 | |
form | string | 底层 input 关联的表单 | |
id | string | 组件内部状态机的唯一标识 | |
ids | Partial<{ root: string; label: string; indicator: string; item(value: string): string; itemLabel(value: string): string; itemControl(value: string): string; itemHiddenInput(value: string): string; }> | 单选组件各元素的 id,适合组合使用 | |
invalid | boolean | 单选组是否无效 | |
modelValue | string | null | 单选组的 v-model 值 | |
name | string | 单选组件 input 字段的 name,用于表单提交 | |
orientation | 'horizontal' | 'vertical' | 单选组的方向 | |
readOnly | boolean | 复选框是否只读 | |
required | boolean | 单选组是否必填 |