Skip to content

FormSelect

A select element which makes passing options easier.

Default Component

html
<form-select
    v-model="selection1"
    :options="['Please', 'Select', 'Me']"
    class="w-full"
/>

Result

Disabled Component

The disabled-label property can be used to display a default option.

html
<form-select
    :disabled="true"
    disabled-label="(I am inactive)"
    class="w-full"
/>

Result

Component With A Set DisabledLabel

The disabled-label property will be displayed when initially no option is selected.

html
<form-select
    v-model="selection2"
    :options="['Please', 'Select', 'Me']"
    disabled-label="(Pick an option)"
    class="w-full"
/>

Result

Component With Key-Label Options

html
<form-select
    v-model="selection3"
    :options="[
        { key: 1, label: 'Option 1' },
        { key: 2, label: 'Option 2' },
        { key: 3, label: 'Option 3' }
    ]"
    disabled-label="(Pick an option)"
    class="w-full"
/>

Result

Properties

NameTypeDefaultDescription
modelValueMixedEither a string or whatever the key property of an option contains
optionsArrayCan be an array of strings or an array of objects with key and label properties
disabledLabelStringDisplayed option if no selection has been made

Events

NameArgumentsDescription
update:modelValueselection - Selected optionDepending on the options this is either a string or the key property of an option object