单选列表
对齐目标:@astryxdesign/core v0.7.1 · RadioList
Notification preference
使用方法 #
RadioList 在一组互斥选项里选一个。默认插槽放 RadioListItem。选项只是纯文本时,也可以传 options 数组。
Vue
<script setup lang="ts">
import { RadioList, RadioListItem } from '@astryx-vue/core/RadioList'
import { shallowRef } from 'vue'
const channel = shallowRef('')
</script>
<template>
<RadioList v-model="channel" label="通知方式">
<RadioListItem label="邮件" value="email" />
<RadioListItem label="短信" value="sms" />
</RadioList>
</template>指示器默认 24px,size="sm" 时是 20px。orientation="horizontal" 把选项排成一行,间距 20px。end 插槽靠行的尾端。
解剖
| 部分 | 说明 |
|---|---|
| 页眉 | 单选列表上方的可选标题。 |
| 子项 | 作为可选项渲染的单选列表项。 |
| 标签和值 | 每个单选项的文字标签,以及对应的值。 |
最佳实践 #
| 指引 | 实践 |
|---|---|
| 推荐 | 选项保持较少,通常 2 到 7 个。 |
| 避免 | 需要多选时使用单选列表。应改用 CheckboxList。 |
| 避免 | 超过大约 4 个选项时用水平排列。 |
示例 #
单选列表 — 水平排列
Size
小号、中号、大号排成一行。
单选列表 — 价格方案
Plan
每个方案在行尾显示价格。
单选列表 — 带说明
Notification preference
Choose how you would like to be notified每个选项下面有一段说明。
单选列表 — 带校验
Notification preference Required
Please select a notification method
必填且未选择时显示错误。