Select 选择器
基于 reka-ui 的组合式选择器。选项较少时也可用 [Radio](/components-library/reui/components/data-entry/radio)。
下拉选择器,支持搜索、分组、异步加载等。基于 reka-ui SelectRoot 封装。
何时使用
- 需要从一组选项中选择一个或多个值时。
- 选项数量较多(> 5)时,比 Radio 更节省空间。
导入
代码演示
基础用法
禁用选项
分组
使用 SelectGroup 分组,SelectLabel 添加分组标题。
尺寸
通过 SelectTrigger 的 size 属性控制尺寸,支持 small / medium / large(默认 default,等价 medium),字号随尺寸切换为 text-xs / text-sm / text-base。
API
Select Props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
modelValue | 当前选中值(v-model) | AcceptableValue | - |
defaultValue | 默认值 | AcceptableValue | - |
disabled | 是否禁用 | boolean | false |
name | 表单字段名 | string | - |
required | 是否必填 | boolean | false |
SelectTrigger Props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
size | 尺寸(兼容旧写法 sm / default / lg) | "small" | "medium" | "large" | "sm" | "default" | "lg" | "default" |
class | 附加类名 | string | - |
SelectContent Props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
position | 定位方式 | "item-aligned" | "popper" | "item-aligned" |
class | 附加类名 | string | - |
SelectItem Props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
value | 选项值 | AcceptableValue | - |
disabled | 是否禁用 | boolean | false |
class | 附加类名 | string | - |
组件组成
| 组件 | 说明 |
|---|---|
Select | 根容器(reka-ui SelectRoot props) |
SelectTrigger | 触发器,含下拉箭头 |
SelectValue | 展示选中值 / 占位文字 |
SelectContent | 下拉内容面板 |
SelectItem | 选项 |
SelectGroup | 分组容器 |
SelectLabel | 分组标签 |
SelectSeparator | 分隔线 |
SelectScrollUpButton | 向上滚动按钮 |
SelectScrollDownButton | 向下滚动按钮 |
SelectItemText | 选项文本(用于跨组件展示选中值) |
