外观
Select 下拉选择框
在自定义下拉列表中选择一个选项,收起后由触发器显示当前值。
import { SSelect } from '@icecreamqaq/shadcn/select'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SSelect.options | readonly SelectOption[] | 传入选项数组,或直接在默认插槽内声明 SSelectItem。 |
SSelect.renderOption / #option | { option } | 自定义选项内容,支持注册组件、VNode 和渲染函数。 |
SSelect.v-model | AcceptableValue | AcceptableValue[] | 绑定选中的值,multiple 模式使用数组。 |
SSelect.v-model:open | boolean | 控制下拉层的打开状态。 |
SSelectTrigger.size | "default" | "sm" | 默认使用 default 高度,可用 sm 放入紧凑的工具栏。 |
SSelectValue.placeholder | string | 没有选中值时在触发器中显示的提示。 |
SSelectItem.value | AcceptableValue | 选择该项时写入模型的值。 |
完整 API
Select22 个成员
属性
| 名称 | 类型 |
|---|---|
open | boolean |
defaultOpen | boolean |
defaultValue | AcceptableValue | AcceptableValue[] |
modelValue | AcceptableValue | AcceptableValue[] |
nullableValue | string |
by | string | ((a: AcceptableValue, b: AcceptableValue) => boolean) |
dir | Direction |
multiple | boolean |
autocomplete | string |
disabled | boolean |
name | string |
required | boolean |
options | readonly SelectEntry[] |
placeholder | string |
renderOption | RenderContent<{ option: SelectOption; }> |
renderValue | RenderContent<{ modelValue: SelectRootProps["modelValue"]; }> |
事件
| 名称 | 类型 |
|---|---|
update:modelValue | ((value: AcceptableValue) => any) |
update:open | ((value: boolean) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((scope: Scope) => VNode[]) |
options | (() => VNode[]) |
option | ((scope: { option: SelectOption; }) => VNode[]) |
value | ((scope: { modelValue: AcceptableValue | AcceptableValue[] | undefined; }) => VNode[]) |
SelectContent33 个成员
属性
| 名称 | 类型 |
|---|---|
forceMount | boolean |
position | "item-aligned" | "popper" |
bodyLock | boolean |
loop | boolean |
memoDependencies | unknown[] |
side | "top" | "right" | "bottom" | "left" |
sideOffset | number |
sideFlip | boolean |
fallbackAxisSideDirection | "none" | "start" | "end" |
align | "start" | "end" | "center" |
alignOffset | number |
alignFlip | boolean |
avoidCollisions | boolean |
collisionBoundary | Element | (Element | null)[] | null |
collisionPadding | number | Partial<Record<"top" | "right" | "bottom" | "left", number>> |
arrowPadding | number |
hideShiftedArrow | boolean |
sticky | "partial" | "always" |
hideWhenDetached | boolean |
positionStrategy | "absolute" | "fixed" |
updatePositionStrategy | "always" | "optimized" |
disableUpdateOnLayoutShift | boolean |
prioritizePosition | boolean |
reference | ReferenceElement |
dir | Direction |
asChild | boolean |
as | AsTag | Component |
disableOutsidePointerEvents | boolean |
class | ClassValue |
事件
| 名称 | 类型 |
|---|---|
escapeKeyDown | ((event: KeyboardEvent) => any) |
pointerDownOutside | ((event: PointerDownOutsideEvent) => any) |
closeAutoFocus | ((event: Event) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
SelectGroup3 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
SelectItem8 个成员
属性
| 名称 | 类型 |
|---|---|
value 必填 | AcceptableValue |
disabled | boolean |
textValue | string |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
indicator-icon | ((props: {}) => any) |
default | ((props: {}) => any) |
SelectItemText3 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
SelectLabel5 个成员
属性
| 名称 | 类型 |
|---|---|
for | string |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
SelectScrollDownButton4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
SelectScrollUpButton4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
SelectSeparator3 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
SelectTrigger7 个成员
属性
| 名称 | 类型 |
|---|---|
disabled | boolean |
reference | ReferenceElement |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
size | "default" | "sm" |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
SelectValue4 个成员
属性
| 名称 | 类型 |
|---|---|
placeholder | string |
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-select>。
组件 SSelect、SSelectContent、SSelectGroup、SSelectItem、SSelectItemText、SSelectLabel、SSelectScrollDownButton、SSelectScrollUpButton、SSelectSeparator、SSelectTrigger、SSelectValue
类型 SelectEntry、SelectOption、SelectOptionGroup