Dropdown
The catnip-dropdown component is a field control for choosing one or many values from a list. Shared label and supporting-text behaviour matches other field inputs; see Inputs overview.
Use the API control (top right) to switch between the options prop and <catnip-dropdown-option> child elements. Pick one API per dropdown — do not combine them. See Specs and Guidelines — Choosing an API for shapes and decision guidance.
What the dropdown owns
Regardless of which options API you use, catnip-dropdown handles:
- Field label, trigger, open state, selection, and keyboard navigation
- List panel (search field, empty state, scroll), rendered right after the field and shown in the top layer, so it isn't clipped and works inside a modal Dialog or Drawer. The list is at least as wide as the trigger and grows with content up to
listMaxWidth(default 320px, never narrower than the trigger). Long option labels wrap. - Multi-select display modes (
value,chips,count)
List and floating-panel internals stay private; compose custom search via listHeader, or use built-in selectAll (multi only) and footer actions via slots.
Live example
The playground matches the selected API above.
When to use
- Catnip dropdown — styled field select with checkmark (single) or checkbox (multi) rows, chips/count trigger modes, and design-system validation states.
- Native
<select>— simple forms where native behaviour is enough; pair withcatnip-field-labelif you need the label row only. - List (internal) — building custom overlays; not a public custom element.
Guidelines
Use the API control (top right) to show guidance for the selected API.
Choosing the options prop
Use when rows are plain { value, label, … } data (static lists, REST/GraphQL, computed filters). Enable filterable for built-in label search, or pre-filter the .options array (.filterLocally="false" for server-side rules). Set hidden: true on objects to hide rows without splicing the array.
Do not add <catnip-dropdown-option> children when using options — they are ignored and a dev warning is logged.
Options prop — recipes
Map API data
type Service = { id: string; name: string; active: boolean };
const services = computed(() =>
apiData.value.map((s) => ({
value: s.id,
label: s.name,
disabled: !s.active
}))
);<catnip-dropdown
label="Service"
.options="services"
.modelValue="selectedServiceId"
@update:modelValue="selectedServiceId = $event.detail[0]"
/>Built-in client filter
Enable filterable. The dropdown filters label text locally (filterLocally defaults to true).
Parent-controlled filter (server or custom rules)
- Own filter state in the parent (
query,@update:filterValue). - Pass a computed
optionsarray (already filtered). - Set
.filterLocally="false"so the dropdown does not filter again.
const query = ref(""); const filtered = computed(() => allServices.value.filter((s) => s.label.includes(query.value)));<catnip-dropdown
filterable
.filterLocally="false"
.options="filtered"
.filterValue="query"
@update:filterValue="query = $event.detail[0]"
…
/>Hide rows without removing them
Set hidden: true on option objects instead of splicing the array when toggling visibility client-side.
Multi-select display
| displayMode | Trigger shows |
|---|---|
value | Comma-separated labels (default) |
chips | Removable catnip-chip chips |
count | "{n} selected" (override with selectedCountLabel) |
Works with both options and child-element APIs.
Validation
Set intent="danger" and supportingText together — same pattern as Input. The dropdown does not mirror native :invalid automatically.
Migration from EndUi (options prop)
| EndUi | Catnip |
|---|---|
options + keyField / valueField | .options prop — map to { value, label } |
allowMultiple | multiple |
useChip | display-mode="chips" |
hasSearch | filterable or listHeader slot |
error / hint | intent + supportingText |