GitHub repository

Select

Styled native dropdown.

A native `<select>` wrapped in the shared field chrome — best-in-class keyboard and mobile a11y, with a custom CSS chevron and zero runtime deps. Pass a flat `options` list or grouped `SelectOptGroup[]` (auto-detected); add a `placeholder` for an empty first choice, and wire `hint`/`error` text via `aria-describedby` exactly like `Input`.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { Select } from 'dssoca';

  let country = $state('');
  const options = [
    { value: 'us', label: 'United States' },
    { value: 'ca', label: 'Canada' },
  ];
</script>

<Select label="Country" bind:value={country} {options} placeholder="Select a country…" />

HTML

CSS only — static markup The exact markup the component renders, generated at build time. Use it with dssoca/vanilla.css — see Plain HTML & CSS.

html
<div class="ss-select">
  <label class="lbl" for="region">Region</label>
  <div class="control">
    <select class="select" id="region">
      <option value="eu" selected="">Europe</option>
      <option value="us">United States</option>
    </select>
    <span class="chevron" aria-hidden="true"></span>
  </div>
</div>

A labelled native <select>.

Props

PropTypeDefaultDescription
optionsSelectOption[] | SelectOptGroup[][]Flat options, or grouped options (detected by an `options` array on the first element).
valuestring''Bindable selected value (`bind:value`).
labelstring—Label text; rendered as <label> wired to the select.
idstring—Select id; auto-generated for label association when unset.
namestring—Native form field name.
placeholderstring—Disabled, hidden first option, selected while the value is empty.
requiredbooleanfalseMarks the field required.
disabledbooleanfalseRenders the select non-interactive.
invalidboolean—Marks the field invalid for assistive tech (aria-invalid).
hintstring—Helper text under the field, wired via aria-describedby.
errorstring—Error text under the field; implies aria-invalid and is announced to AT (role="alert").
describedbystring—Extra id(s) appended to aria-describedby after error/hint.
onchange(e: Event) => void—Native change handler; fired on selection.
size'sm' | 'md' | 'lg'—Per-instance size override; inherits the ancestor `data-size-variant` when unset.
↑↓ navigate · ↵ open · esc close

Keyboard shortcuts

No shortcuts registered

Shortcuts added through the dssoca registry will show up here.

Single-key shortcuts