Skip to content

Select ​

Accessible custom select with a combobox trigger and listbox popup.

@zeus-web/selectData Entryzweb add selectGenerated

Playground ​

Source ​

Choose the framework entry that matches your application.

html
<script type="module">
  import '@zeus-web/select/wc/auto'
</script>

<zw-select aria-label="Environment">
  <option value="preview">Preview</option>
  <option value="production">Production</option>
</zw-select>
tsx
import { Select } from '@zeus-web/select/react'

export function SelectExample() {
  return (
    <Select aria-label="Environment">
      <option value="preview">Preview</option>
      <option value="production">Production</option>
    </Select>
  )
}
vue
<script setup lang="ts">
import { Select } from '@zeus-web/select/vue'
</script>

<template>
  <Select aria-label="Environment">
    <option value="preview">Preview</option>
    <option value="production">Production</option>
  </Select>
</template>

Add ​

bash
zweb add select

Imports ​

Styled registry component:

tsx
import { Select } from '@/components/ui/select'

Primitive React wrapper:

tsx
import { Select } from '@zeus-web/select/react'

Web Component entry:

ts
import '@zeus-web/select/wc/auto'

Props ​

PropTypeDefaultDescription
idstring-Base ID used to derive the internal trigger ID; the listbox keeps its generated ID.
valuestring-Current selected value.
defaultValuestring-Initial selected value.
valuesstring[]-Current selected values in multiple mode. Pass as a JavaScript property.
defaultValuesstring[]-Initial selected values in multiple mode. Pass as a JavaScript property.
placeholderstring-Text shown when no option is selected.
sizeSelectSize
Values: sm, md, lg
mdSelect control size.
multipleboolean-Enables multiple selection.
disabledboolean-Disables user interaction.
requiredboolean-Marks the select as required for form validation.
invalidboolean-Marks the select as invalid.
namestring-Form field name used during submission.
ariaLabelstring-Accessible label for unlabeled selects.
ariaLabelledbystring-ID reference for the visible select label.
ariaDescribedbystring-ID reference for additional accessible description.
ariaErrormessagestring-ID reference for the accessible error message.

Events ​

EventReact propDetailDescription
value-changeonValueChangevalue: string, values: string[], nativeEvent: EventEmitted when selected value changes.
focus-changeonFocusChangefocused: boolean, nativeEvent: FocusEventEmitted when focus enters or leaves the select trigger.

Slots ​

SlotDescription
defaultOption children used as the select data source.

Styling ​

Uses Tailwind: yes

Theme tokens:

  • border-input
  • bg-popover
  • text-popover-foreground
  • bg-accent
  • ring-ring

Internal selectors:

  • [data-slot=select-trigger]
  • [data-slot=select-content]
  • [data-slot=select-option]
  • [data-slot=select-option-indicator]
  • [data-slot=select-message]

Registry ​

Registry source: available.

Add command: zweb add select

Type: component

Dependencies:

  • @zeus-web/select

Registry dependencies:

  • cn
  • globals

Files:

  • templates/react/select.tsx → components/ui/select.tsx
  • templates/vue/select.ts → components/ui/select.ts

AI usage rules ​

Do:

  • Use Select for single or multiple choice lists with keyboard navigation.
  • Use placeholder when the field has no initial selection.
  • Set values and defaultValues as JavaScript properties, not HTML attributes.

Do not:

  • Do not use Select for free-form text entry or remote autocomplete.

Examples ​

React styled usage ​

tsx
import { Select } from '@/components/ui/select'

export function Example() {
  return (
    <Select defaultValue="apple">
      <option value="apple">Apple</option>
      <option value="orange">Orange</option>
    </Select>
  )
}

Released under the MIT License.