跳至正文

Select 下拉选择框 ​

在自定义下拉列表中选择一个选项,收起后由触发器显示当前值。

import { SSelect } from '@icecreamqaq/shadcn/select'

使用示例 ​

基础用法
分组选项与自定义渲染

常用 API ​

成员类型用法
SSelect.optionsreadonly SelectOption[]传入选项数组,或直接在默认插槽内声明 SSelectItem。
SSelect.renderOption / #option{ option }自定义选项内容,支持注册组件、VNode 和渲染函数。
SSelect.v-modelAcceptableValue | AcceptableValue[]绑定选中的值,multiple 模式使用数组。
SSelect.v-model:openboolean控制下拉层的打开状态。
SSelectTrigger.size"default" | "sm"默认使用 default 高度,可用 sm 放入紧凑的工具栏。
SSelectValue.placeholderstring没有选中值时在触发器中显示的提示。
SSelectItem.valueAcceptableValue选择该项时写入模型的值。

完整 API ​

Select22 个成员

属性

名称类型
openboolean
defaultOpenboolean
defaultValueAcceptableValue | AcceptableValue[]
modelValueAcceptableValue | AcceptableValue[]
nullableValuestring
bystring | ((a: AcceptableValue, b: AcceptableValue) => boolean)
dirDirection
multipleboolean
autocompletestring
disabledboolean
namestring
requiredboolean
optionsreadonly SelectEntry[]
placeholderstring
renderOptionRenderContent<{ option: SelectOption; }>
renderValueRenderContent<{ 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 个成员

属性

名称类型
forceMountboolean
position"item-aligned" | "popper"
bodyLockboolean
loopboolean
memoDependenciesunknown[]
side"top" | "right" | "bottom" | "left"
sideOffsetnumber
sideFlipboolean
fallbackAxisSideDirection"none" | "start" | "end"
align"start" | "end" | "center"
alignOffsetnumber
alignFlipboolean
avoidCollisionsboolean
collisionBoundaryElement | (Element | null)[] | null
collisionPaddingnumber | Partial<Record<"top" | "right" | "bottom" | "left", number>>
arrowPaddingnumber
hideShiftedArrowboolean
sticky"partial" | "always"
hideWhenDetachedboolean
positionStrategy"absolute" | "fixed"
updatePositionStrategy"always" | "optimized"
disableUpdateOnLayoutShiftboolean
prioritizePositionboolean
referenceReferenceElement
dirDirection
asChildboolean
asAsTag | Component
disableOutsidePointerEventsboolean
classClassValue

事件

名称类型
escapeKeyDown((event: KeyboardEvent) => any)
pointerDownOutside((event: PointerDownOutsideEvent) => any)
closeAutoFocus((event: Event) => any)

插槽

名称类型
default((props: {}) => any)
SelectGroup3 个成员

属性

名称类型
asChildboolean
asAsTag | Component

插槽

名称类型
default((props: {}) => any)
SelectItem8 个成员

属性

名称类型
value 必填AcceptableValue
disabledboolean
textValuestring
asChildboolean
asAsTag | Component
classClassValue

插槽

名称类型
indicator-icon((props: {}) => any)
default((props: {}) => any)
SelectItemText3 个成员

属性

名称类型
asChildboolean
asAsTag | Component

插槽

名称类型
default((props: {}) => any)
SelectLabel5 个成员

属性

名称类型
forstring
asChildboolean
asAsTag | Component
classClassValue

插槽

名称类型
default((props: {}) => any)
SelectScrollDownButton4 个成员

属性

名称类型
asChildboolean
asAsTag | Component
classClassValue

插槽

名称类型
default((props: {}) => any)
SelectScrollUpButton4 个成员

属性

名称类型
asChildboolean
asAsTag | Component
classClassValue

插槽

名称类型
default((props: {}) => any)
SelectSeparator3 个成员

属性

名称类型
asChildboolean
asAsTag | Component
classClassValue
SelectTrigger7 个成员

属性

名称类型
disabledboolean
referenceReferenceElement
asChildboolean
asAsTag | Component
classClassValue
size"default" | "sm"

插槽

名称类型
default((props: {}) => any)
SelectValue4 个成员

属性

名称类型
placeholderstring
asChildboolean
asAsTag | Component

插槽

名称类型
default((props: {}) => any)

分组导出 ​

模板标签为 <s-select>。

组件 SSelect、SSelectContent、SSelectGroup、SSelectItem、SSelectItemText、SSelectLabel、SSelectScrollDownButton、SSelectScrollUpButton、SSelectSeparator、SSelectTrigger、SSelectValue

类型 SelectEntry、SelectOption、SelectOptionGroup