Products · Components

Select

A field that opens a list of options to choose one from.

Put an Option inside it for each choice. The choices open in a sheet.

Children: Components

Example

The Select component
view.dml
<Select label="Delivery" placeholder="Choose how" value="{{ delivery }}" onChange="setDelivery">
  <Option value="pickup" label="Pick up in store" />
  <Option value="courier" label="Courier" />
  <Option value="post" label="Post" />
</Select>
controller.ts
export default definePage({
  initialState: { delivery: 'pickup' },
  mutations: {
    setDelivery: (_state, event: ValueEvent) => ({ delivery: event.detail.value }),
  },
});

Props

PropTypeWhat it is
valuestringThe chosen option's value.
labelstring
placeholderstring
hintstringHelp shown under the field, which error replaces.
errorstringShown under the field in red, in place of hint.
disabledbooleanDims it, and the person can't use it.

Events

EventSendsNotes
onChange{ value } in detailThe chosen option's value.

Keep reading

On this page