Skip to content

SelectPicker ​

Used for single or multiple selection from a set of options.

Basic Usage ​

label sets the left text content;

columns sets the data source, a one-dimensional array where each option contains value (option value) and label (option name);

v-model sets the value of selected items, data type can be Array | String Number or Boolean;

html
<wd-select-picker label="Basic Usage" v-model="value" :columns="columns" @change="handleChange"></wd-select-picker>
typescript
const columns = ref<Record<string, any>>([{
  value: '101',
  label: 'Men\'s Clothing'
}, {
  value: '102',
  label: 'Luxury Goods'
}, {
  value: '103',
  label: 'Women\'s Clothing'
}])
const value = ref<string[]>(['101'])

function handleChange({ value }) {
  toast.show('Selected ' + value)
}

Type Switch ​

type defaults to checkbox, when it's the default value, the value type is Array

Set type to radio to enable single selection mode, where value type can be String Number or Boolean.

html
<wd-select-picker label="Type Switch" v-model="value" :columns="columns" type="radio"></wd-select-picker>
typescript
const columns = ref<Record<string, any>>([{
  value: '101',
  label: 'Men\'s Clothing'
}, {
  value: '102',
  label: 'Luxury Goods'
}, {
  value: '103',
  label: 'Women\'s Clothing'
}])
const value = ref<string[]>(['101'])

Disabled ​

Set the disabled property.

html
<wd-select-picker label="Disabled" v-model="value" :columns="columns" disabled></wd-select-picker>

Readonly ​

Set the readonly property.

html
<wd-select-picker label="Readonly" v-model="value" :columns="columns" readonly></wd-select-picker>

Clearable ​

Set the clearable property

html
<wd-select-picker label="Clearable" v-model="value" :columns="columns" clearable></wd-select-picker>

Disabled Options ​

Each option in columns supports the disabled property.

html
<wd-select-picker label="Disabled Options" v-model="value" :columns="columns"></wd-select-picker>
typescript
const columns = ref<Record<string, any>>([{
  value: '101',
  label: 'Men\'s Clothing',
  disabled: true
}, {
  value: '102',
  label: 'Luxury Goods'
}, {
  value: '103',
  label: 'Women\'s Clothing'
}])
const value = ref<string[]>(['101'])

Display Formatting ​

Set the display-format property, which is a function type that receives the current selected item (when type is checkbox the parameter is array type, when type is radio the parameter is String Number or Boolean type) and the current options array columns, returns the string to be displayed.

html
<wd-select-picker label="Display Formatting" v-model="value" :columns="columns" :display-format="displayFormat"></wd-select-picker>
typescript
const columns = ref<Record<string, any>>([{
  value: '101',
  label: 'Men\'s Clothing',
  disabled: true
}, {
  value: '102',
  label: 'Luxury Goods'
}, {
  value: '103',
  label: 'Women\'s Clothing'
}])
const value = ref<string[]>(['101'])

const displayFormat = (items, columns) => {
  let showValue = ''
  columns.forEach((column) => {
    items.forEach((item, index) => {
      if (column.value === item) {
        showValue += `${item}: ${column.label} ${index + 1 < items.length ? '--' : ''} `
      }
    })
  })
  return showValue
}

Validation Before Confirmation ​

Set the before-confirm function, which will be executed when the user clicks the confirm button. It receives value (selected items, which is the currently selected value) and resolve parameters. You can validate the value and use the resolve function to tell the component whether to confirm. resolve accepts 1 boolean value, resolve(true) means the option passes, resolve(false) means the option doesn't pass, and the popup won't close when it doesn't pass.

html
<wd-select-picker label="Validation Before Confirmation" v-model="value" :columns="columns" :before-confirm="beforeConfirm"></wd-select-picker>
typescript
const columns = ref<Record<string, any>>([{
  value: '101',
  label: 'Men\'s Clothing'
}, {
  value: '102',
  label: 'Luxury Goods'
}, {
  value: '103',
  label: 'Women\'s Clothing'
}])
const value = ref<string[]>(['101'])

const beforeConfirm = (value, resolve) => {
  if (value.length > 0) {
    toast.error('Unable to select products at this time')
    resolve(false)
  } else {
    resolve(true)
  }
}

Setting Title ​

Set the title property to modify the popup layer's title.

html
<wd-select-picker label="Title" v-model="value" :columns="columns" title="Multiple Selection"></wd-select-picker>

Error State ​

Set the error property or error-message property to display the error state.

html
<wd-select-picker label="Error State" v-model="value" :columns="columns" error></wd-select-picker>
<wd-select-picker label="Error Message" v-model="value" :columns="columns" error-message="Error Message"></wd-select-picker>

Custom Label Width ​

Set the label-width property to customize the label width. The default is '33%'.

html
<wd-select-picker label="Label Width" v-model="value" :columns="columns" label-width="100px"></wd-select-picker>

Size ​

Set the size property to customize the size. The default is ''.

html
<wd-select-picker label="Large" v-model="value" :columns="columns" size="large"></wd-select-picker>
<wd-select-picker label="Small" v-model="value" :columns="columns" size="small"></wd-select-picker>

Align ​

Set the align property to customize the alignment of the right content. The default is 'left'.

html
<wd-select-picker label="Align" v-model="value" :columns="columns" align="right"></wd-select-picker>

Custom Value Key ​

Set the value-key property to customize the key name of the option value.

html
<wd-select-picker label="Custom Value Key" v-model="value" :columns="columns" value-key="value"></wd-select-picker>

Custom Label Key ​

Set the label-key property to customize the key name of the option label.

html
<wd-select-picker label="Custom Label Key" v-model="value" :columns="columns" label-key="label"></wd-select-picker>

Attributes ​

AttributeDescriptionTypeDefaultVersion
v-modelSelected valuestring / number / boolean / array--
columnsOptionsarray--
typeType, 'checkbox' or 'radio'string'checkbox'-
value-keyCustomize the key name of option valuestring'value'-
label-keyCustomize the key name of option labelstring'label'-
titleTitlestring--
labelLeft textstring--
placeholderPlaceholderstring'请选择'-
disabledDisabledbooleanfalse-
readonlyReadonlybooleanfalse-
loadingLoadingbooleanfalse-
loading-colorLoading colorstring'#4D80F0'-
label-widthLabel widthstring'33%'-
sizeSizestring--
errorWhether to be in error statebooleanfalse-
error-messageError messagestring--
requiredWhether to display the required asteriskbooleanfalse-
marker-sidePosition of the required marker'before' | 'after''before'1.12.0
alignAlignment of right contentstring'left'-
before-confirmValidation function before confirmingfunction--
display-formatDisplay format functionfunction--
close-on-click-modalWhether to close when clicking modalbooleantrue-
safe-area-inset-bottomWhether to enable bottom safe area adaptationbooleantrue-
root-portalWhether to detach from the page, used to solve various fixed positioning issuesbooleanfalse1.11.0
clearableShow clear buttonbooleanfalse1.11.0

Events ​

EventDescriptionParametersVersion
confirmTriggered when clicking confirm buttonvalue-
cancelTriggered when clicking cancel button--
changeTriggered when value changesvalue-
focusTriggered when focusing--
blurTriggered when blurring--
clearTriggered when clicking clear button-1.11.0

Methods ​

MethodDescriptionParametersVersion
openOpen popup--
closeClose popup--

Slots ​

NameDescriptionVersion
labelCustom label-
defaultContent after value-

Source Code ​

Documentation
• Component

Released under the MIT License.

Released under the MIT License.