Skip to content

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.

Component Source
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.

Component Source
<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.

Component Source
<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.

Component Source
<Dropdown placement="top" align="end" ariaLabel="Period" defaultValue="this-year" options={PERIODS} />

States

Disabled

Component Source
<Dropdown ariaLabel="Period" defaultValue="this-month" options={PERIODS} disabled />

Select, Dropdown or Combobox

SelectDropdownCombobox
Best forPicking one value from a styled list, with groups or leading iconsCompact pickers and filters; the native variant for the OS picker on phonesLong lists people search by typing, or values that may not be in the list
PopupCustom listbox (Radix Select)Custom listbox by default; variant="native" renders a real <select>Text input with a filtered list
Free textNoNoYes, any typed string is the value
Options{ value, label, prefix? } or groups{ value, label }Strings
Sizessm, md, lgsm, mdsm, md
Empty stateShows placeholder until something is pickedStarts on the first optionShows 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

PropTypeDefaultDescription
valuestring—Active selected option value string (controlled). Omit and use `defaultValue` for uncontrolled.
defaultValuestring—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 }).
disabledboolean—Whether control is disabled.
variant"native" | "default"(customRendering variant: native (<select>) or default (custom popup). Default 'default'.
placement"bottom" | "top"bottomPopup placement relative to trigger: 'bottom' or 'top'. Default 'bottom'.
align"start" | "end"startPopup horizontal alignment relative to trigger: 'start' (left) or 'end' (right). Default 'start'.
ariaLabelstring—Accessible ARIA label.
classNamestring—Optional custom CSS class name.
idstring—id of the control, so a `<label htmlFor>` can name it.
namestring—Form field name.
requiredboolean—Marks the field required.
size"sm" | "md""md"—
appearance"default" | "ghost""default"—

* required

Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font