单选框组
一组可供选择的按钮——称为单选框——同一时间最多只能选中其中一个按钮。
安装
pnpm dlx shadcn-vue@latest add radio-group
用法
vue
<script setup lang="ts">
import { Label } from '@/components/ui/label'
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
</script>
<template>
<RadioGroup default-value="option-one">
<div class="flex items-center space-x-2">
<RadioGroupItem id="option-one" value="option-one" />
<Label for="option-one">选项一</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroupItem id="option-two" value="option-two" />
<Label for="option-two">选项二</Label>
</div>
</RadioGroup>
</template>示例
表单
请先阅读 vee-validate 文档中关于 复选框和单选框输入 的部分