KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Forms

kt-select

GitHub Copy link

A single-choice dropdown.

Preview

A single-choice dropdown.

<kt-select placeholder="Select a region" name="region"></kt-select>select.options = [ { id: 'ne', label: 'North East' }, { id: 'sw', label: 'South West' }, { id: 'nw', label: 'North West', disabled: true }, ]; select.addEventListener('kt-change', (e) => console.log(e.detail.value, e.detail.option));

options is a property, not an attribute — it is data, and serialising an array of objects through an HTML attribute is a mistake you only make once.

Keyboard

This is a real listbox, not a button next to a floating div:

KeyDoes
↓ / ↑Opens the list, then moves the active option
Home / EndJumps to the first / last selectable option
Enter / SpaceOpens, then commits the active option
EscapeCloses, changing nothing
TabCloses and moves on

Disabled options are skipped by the arrows rather than merely being unclickable, and the trigger carries aria-activedescendant so a screen reader follows the highlight.

Animation

The popup stays in the DOM and animates through opacity and transform, held out of the way with visibility: hidden. A popup that unmounts cannot animate out; one that only toggles display cannot animate at all.

API

PropertyAttributeTypeDefault
options—KtOption[][]
valuevaluestring | number | nullnull
placeholderplaceholderstring'Select'
namenamestring''
sizesize'small' | 'medium' | 'large''medium'
disableddisabledbooleanfalse
requiredrequiredbooleanfalse
errorerrorstring''
clearableclearablebooleantrue
labellabelstring''
emptyTextempty-textstring'No options…'
interface KtOption { id: string | number; label?: string; // falls back to String(id) disabled?: boolean; }
GetterReturns
selectedOptionThe chosen KtOption, or undefined
EventDetail
kt-change{ value: string | number | null, option: KtOption | null }
PartDescription
triggerThe button
popupThe option list
optionAn option row