Dropdown
A simple control for picking one value from a short list. It uses a styled popup, or the browser's own select menu.
// Radix — @radix-ui/react-select
import { Dropdown } from "@shavin/ui";Variants
The variant prop picks how the list renders. Both variants take the same value, onChange and options. Unlike Select, Dropdown has no placeholder: with no value it starts on the first option.
Default: custom popup
A styled listbox built on Radix Select, with arrow keys, type-ahead and Escape.
import { useState } from "react";
import { Dropdown } from "@shavin/ui";
const PERIODS = [
{ value: "this-month", label: "This month" },
{ value: "last-month", label: "Last month" },
{ value: "this-year", label: "This year" },
];
export function PeriodPicker() {
const [period, setPeriod] = useState("this-month");
return (
<div className="flex w-56 flex-col gap-3">
<Dropdown ariaLabel="Period" size="md" value={period} onChange={setPeriod} options={PERIODS} />
<Dropdown ariaLabel="Period, small" size="sm" value={period} onChange={setPeriod} options={PERIODS} />
</div>
);
}Native: the OS picker
Renders a real <select>, so phones show their own picker. Good for simple, mobile-first forms.
<Dropdown variant="native" ariaLabel="Period" value={period} onChange={setPeriod} options={PERIODS} />Appearance
Ghost
No border or fill until hover. Use it for filters in toolbars and table headers.
<Dropdown appearance="ghost" size="sm" ariaLabel="Period" defaultValue="last-month" options={PERIODS} />Placement
Open upwards, align to the end
placement (bottom or top) and align (start or end) position the default popup. They have no effect on the native variant.
<Dropdown placement="top" align="end" ariaLabel="Period" defaultValue="this-year" options={PERIODS} />States
Disabled
<Dropdown ariaLabel="Period" defaultValue="this-month" options={PERIODS} disabled />Select, Dropdown or Combobox
| Select | Dropdown | Combobox | |
|---|---|---|---|
| Best for | Picking one value from a styled list, with groups or leading icons | Compact pickers and filters; the native variant for the OS picker on phones | Long lists people search by typing, or values that may not be in the list |
| Popup | Custom listbox (Radix Select) | Custom listbox by default; variant="native" renders a real <select> | Text input with a filtered list |
| Free text | No | No | Yes, any typed string is the value |
| Options | { value, label, prefix? } or groups | { value, label } | Strings |
| Sizes | sm, md, lg | sm, md | sm, md |
| Empty state | Shows placeholder until something is picked | Starts on the first option | Shows placeholder while empty |
All three support arrow keys, Enter and Escape. Select and the default Dropdown also jump to an option as you type its first letters.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | Active selected option value string (controlled). Omit and use `defaultValue` for uncontrolled. |
| defaultValue | string | — | Initial selected value when uncontrolled. |
| onChange | (v: string) => void | — | Callback fired when selected option value changes. |
| onValueChange | (v: string) => void | — | Alias of `onChange`. |
| options* | DropdownOption[] | — | List of dropdown options ({ value, label }). |
| disabled | boolean | — | Whether control is disabled. |
| variant | "native" | "default" | (custom | Rendering variant: native (<select>) or default (custom popup). Default 'default'. |
| placement | "bottom" | "top" | bottom | Popup placement relative to trigger: 'bottom' or 'top'. Default 'bottom'. |
| align | "start" | "end" | start | Popup horizontal alignment relative to trigger: 'start' (left) or 'end' (right). Default 'start'. |
| ariaLabel | string | — | Accessible ARIA label. |
| className | string | — | Optional custom CSS class name. |
| id | string | — | id of the control, so a `<label htmlFor>` can name it. |
| name | string | — | Form field name. |
| required | boolean | — | Marks the field required. |
| size | "sm" | "md" | "md" | — |
| appearance | "default" | "ghost" | "default" | — |
* required