Skip to content

Select ​

Brief Introduction ​

The select component is used for users to choose one or more options from a dropdown list.
There are two ways to implement the selector tags: <MYSelect /> or <MYSelect></MYSelect><MYOption /> or <MYOption></MYOption>

Basic Usage ​

Use v-model to bind the selected value.

Code Demo
Please select a fruit
展开代码

Disabled State ​

Disable Entire Selector ​

Use the disabled property to disable the selector.

Code Demo
Disabled state
展开代码

Disable a Specific Option ​

Use the disabled property to disable a single option.

Code Demo
Disable an option
展开代码

Custom Size ​

Use the width and height properties to customize the selector's width and height.

Code Demo
Width 300px Height 50px
展开代码

Custom Colors ​

Use the backgroundColor, hoverbackgroundColor, and borderColor properties to customize the selector's colors.

Code Demo
Custom colors
展开代码

API Reference ​

Select Props ​

ParameterDescriptionTypeOptionsDefault
modelValueBound valuestring | number—''
placeholderPlaceholder textstring—'Please select'
disabledWhether disabledboolean—false
widthWidthstring | number—'260px'
heightHeightstring | number—'40px'
backgroundColorBackground colorstring—''
hoverbackgroundColorHover background colorstring—''
borderColorBorder colorstring—''
autoScrollbarAuto scrollbarboolean—true

Option Props ​

ParameterDescriptionTypeOptionsDefault
valueOption valuestring | number——
labelOption labelstring—''
disabledWhether disabledboolean—false

Type Definitions ​

typescript
interface SelectProps {
  modelValue?: string | number;
  placeholder?: string;
  disabled?: boolean;
  width?: string | number;
  height?: string | number;
  backgroundColor?: string;
  hoverbackgroundColor?: string;
  borderColor?: string;
  autoScrollbar?: boolean;
}

interface OptionProps {
  value: string | number;
  label?: string;
  disabled?: boolean;
}

Released under the MIT License.