Skip to content
Pixelbits
Docs / Select
Forms

Select

Pick one value from a short list. A button opens a listbox in the top layer (the native popover API, so it is never clipped by a parent; it closes on outside click, Escape and Tab). Keyboard: Enter, Space or arrows open; arrows, Home and End move; typing jumps to a matching option; Enter or Space picks.

For long lists where people type to search, use Combobox.

Installation

npm: import
import { Select } from "pixelbits/select";
shadcn: copy the source
npx shadcn add https://pixelbits.ali-moradi-develop.com/r/select.json

API

<Select>

Pick one value from a short list. A button opens a listbox in the top layer (the native popover API, so it is never clipped by a parent; it closes on outside click, Escape and Tab). Keyboard: Enter, Space or arrows open; arrows, Home and End move; typing jumps to a matching option; Enter or Space picks.

For long lists where people type to search, use Combobox.

Example
<Field label="Framework">
  <Select
    options={[{ value: "next", label: "Next.js" }, { value: "astro", label: "Astro" }]}
    defaultValue="next"
  />
</Field>
PropTypeDefaultDescription
options*Option[]—

The choices, in order.

valuestring—

The selected value (controlled). Use "" for none.

defaultValuestring—

The value selected at first (uncontrolled).

onValueChange(value: string) => void—

Called with the value the user picked.

placeholderstring"Select…"

Text shown when nothing is selected.

namestring—

Form field name: a hidden input carries the value in form submissions.

size"sm" | "md" | "lg""md"

Height: "sm" 32 px, "md" 40 px, "lg" 48 px.

Also accepts every prop of Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value" | "defaultValue" | "onChange">.