Skip to content

GkSelect

Native <select> backed by an options array. This stays close to the platform—no menu, virtual list, or combobox (those belong in app code or a future headless primitive).

When to use

Use for native single or multi-select controls where platform keyboard behavior is preferred over a custom combobox UI.

Live demo

Basic

Advanced

Edge case

API

Props

PropTypeDefaultDescription
modelValuestring | number | (string | number)[] | undefinedSelected value; array when multiple is true
optionsGkSelectOption[]requiredOptions list
idstringOverrides injected field id
namestringForm name
disabledbooleanfalseDisabled
readonlybooleanfalseReverts change and sets aria-readonly (native readonly is not reliable on <select>)
multiplebooleanfalseNative multiple; use an array modelValue
requiredbooleanNative required
sizenumberNative size (visible rows, often with multiple)
placeholderstringFirst disabled option (value="")
autocompletestringNative autocomplete
ariaLabelstringWhen not inside GkField

Root class applies to the wrapper; other attributes are forwarded to <select>.

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

Events

EventPayloadDescription
update:modelValuestring | number | (string | number)[] | undefinedNew selection
update:focusedbooleantrue on focus, false on blur

Expose

NameTypeDescription
selectHTMLSelectElementNative <select>

Examples

Basic

vue
<script setup lang="ts">
import { GkSelect } from 'god-kit/vue'
import { ref } from 'vue'

const value = ref<string | undefined>()
const options = [
  { value: 'a', label: 'Alpha' },
  { value: 'b', label: 'Beta' },
]
</script>

<template>
  <GkSelect v-model="value" :options="options" aria-label="Choose" placeholder="Pick…" />
</template>

Advanced

vue
<script setup lang="ts">
import { ref } from 'vue'
const tags = ref<string[]>([])
const options = [
  { value: 'a', label: 'Alpha' },
  { value: 'b', label: 'Beta' },
]
</script>

<template>
  <GkSelect v-model="tags" :options="options" multiple :size="4" aria-label="Tags" />
</template>

Edge case

vue
<GkField label="Readonly option set" :error="error">
  <GkSelect
    v-model="reviewValue"
    :options="options"
    readonly
    required
  />
</GkField>

Accessibility notes

  • Wrap with GkField for visible labels and error semantics in forms.
  • Provide ariaLabel when used standalone.
  • For multiple, choose an appropriate size so keyboard selection remains clear.

Released under the MIT License.