Select

Dropdown select with aligned popup.

Installation

npx @noarka/cli add select

Usage

tsx
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@noarka/ui";
tsx
<div className="max-w-xs">  <Select defaultValue="system">    <SelectTrigger>      <SelectValue />    </SelectTrigger>    <SelectContent>      <SelectItem value="system">System</SelectItem>      <SelectItem value="light">Light</SelectItem>      <SelectItem value="dark">Dark</SelectItem>    </SelectContent>  </Select></div>

Examples

With label

Pair the select with a form label.

Grouped options

Group items under labels with separators. Items accept disabled.

Disabled

The whole select locks with a single prop.

API reference

Select

PropTypeDefault
value

Controlled selected value. Use with onValueChange.

string-
defaultValue

Initially selected value when uncontrolled.

string-
onValueChange

Called when the selection changes.

(value: string) => void-
open

Controlled open state. Use with onOpenChange.

boolean-
defaultOpen

Initially open when uncontrolled.

booleanfalse
disabled

Disable the trigger and popup.

booleanfalse
required

Require a selection before form submit.

booleanfalse
name

Identifies the field when the form is submitted.

string-

SelectTrigger

PropTypeDefault
size

Density. Both sizes currently share the h-8 height.

"sm" | "default""default"
render

Polymorphic render prop.

ReactElement | ((props) => ReactNode)-
className

Additional classes merged with the default trigger styles.

string-

SelectValue

PropTypeDefault
children

Placeholder rendered when nothing is selected.

ReactNode-
className

Additional classes merged with the default value styles.

string-

SelectContent

PropTypeDefault
side

Preferred placement side.

"top" | "right" | "bottom" | "left""bottom"
sideOffset

Gap between trigger and popup.

number4
align

Alignment against the trigger edge.

"start" | "center" | "end""center"
alignOffset

Offset along the alignment axis.

number0
alignItemWithTrigger

Line up the selected item with the trigger.

booleantrue
render

Polymorphic render prop. Use to render a custom element instead of the default popup.

ReactElement | ((props) => ReactNode)-
className

Additional classes merged with the default popup styles.

string-

SelectItem

PropTypeDefault
value

Value set on the group when selected.

string-
disabled

Disable the item.

booleanfalse
render

Polymorphic render prop.

ReactElement | ((props) => ReactNode)-
className

Additional classes merged with the default item styles.

string-

SelectGroup

PropTypeDefault
className

Additional classes merged with the default group styles.

string-

SelectLabel

PropTypeDefault
className

Additional classes merged with the default group label styles.

string-

SelectSeparator

PropTypeDefault
className

Additional classes merged with the default separator styles.

string-