ReScript Shadcn
Get started
  • Installation
Components
  • Accordion
  • Alert
  • AlertDialog
  • AspectRatio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • ContextMenu
  • DataTable
  • DatePicker
  • Dialog
  • Direction
  • Drawer
  • DropdownMenu
  • Empty
  • Field
  • HoverCard
  • Input
  • InputGroup
  • InputOtp
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • MessageScroller
  • NativeSelect
  • NavigationMenu
  • Pagination
  • Popover
  • Progress
  • RadioGroup
  • Resizable
  • ScrollArea
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • ToggleGroup
  • Tooltip
  • Typography

Select

Displays a list of options for the user to pick from—triggered by a button.

Installation#

npx shadcn@latest add @rescript-shadcn/Select

Usage#

<Select>
  <Select.Trigger className="w-[180px]">
    <Select.Value placeholder="Theme" />
  </Select.Trigger>
  <Select.Content>
    <Select.Group>
      <Select.Item value="light"> {"Light"->React.string} </Select.Item>
      <Select.Item value="dark"> {"Dark"->React.string} </Select.Item>
      <Select.Item value="system"> {"System"->React.string} </Select.Item>
    </Select.Group>
  </Select.Content>
</Select>

Examples#

Align Item With Trigger#

Use alignItemWithTrigger on SelectContent to control whether the selected item aligns with the trigger. When true (default), the popup positions so the selected item appears over the trigger. When false, the popup aligns to the trigger edge.

Toggle to align the item with the trigger.

Groups#

Use SelectGroup, SelectLabel, and SelectSeparator to organize items.

Scrollable#

A select with many items that scrolls.

Disabled#

Invalid#

Add the data-invalid attribute to the Field component and the aria-invalid attribute to the SelectTrigger component to show an error state.

<Field data-invalid>
  <FieldLabel>Fruit</FieldLabel>
  <SelectTrigger aria-invalid>
    <SelectValue />
  </SelectTrigger>
</Field>
Please select a fruit.

API Reference#

See the Base UI Select documentation.

let items: array<BaseUi.Select.Item.t<null<string>>> = [
  {label: "Select a fruit", value: Null.null},
  {label: "Apple", value: Value("apple")},
@@directive("'use client'")

let items: array<BaseUi.Select.Item.t<option<string>>> = [
let fruits: array<BaseUi.Select.Item.t<null<string>>> = [
  {label: "Apple", value: Null.Value("apple")},
  {label: "Banana", value: Value("banana")},
let northAmerica: array<BaseUi.Select.Item.t<null<string>>> = [
  {label: "Eastern Standard Time", value: Null.Value("est")},
  {label: "Central Standard Time", value: Value("cst")},
type row = {
  label: string,
  value: null<string>,
let items: array<BaseUi.Select.Item.t<null<string>>> = [
  {label: "Select a fruit", value: Null.null},
  {label: "Apple", value: Value("apple")},