Skip to content

SelectField

Dropdown select with options.

Import

ts
import { SelectField, type SelectOption } from '@four-bytes/four-tailwind-ui'

Basic Usage

vue
<script setup>
import { ref } from 'vue'
import { SelectField, type SelectOption } from '@four-bytes/four-tailwind-ui'

const selected = ref('')

const options: SelectOption[] = [
  { value: 'de', label: 'Deutschland' },
  { value: 'at', label: 'Oesterreich' },
  { value: 'ch', label: 'Schweiz' },
]
</script>

<template>
  <SelectField v-model="selected" label="Land" :options="options" />
</template>

With Placeholder

vue
<SelectField 
  v-model="selected" 
  label="Land" 
  :options="options"
  placeholder="Bitte waehlen..."
/>

With Error

vue
<SelectField 
  v-model="selected" 
  label="Land" 
  :options="options"
  error="Bitte waehlen Sie ein Land"
/>

Props

PropTypeDefaultDescription
modelValuestring | number-Selected value (v-model)
optionsSelectOption[][]Available options
labelstring-Field label
placeholderstring-Placeholder text
errorstring-Error message
disabledbooleanfalseDisable select
requiredbooleanfalseMark as required

Types

ts
interface SelectOption {
  value: string | number
  label: string
}

Released under the MIT License.