Dinachi

Select

A form control for choosing one option from a list of predefined values.

#Installation

npx @dinachi/cli@latest add select

#Usage

tsx
import {
  Select,
  SelectGroup,
  SelectValue,
  SelectTrigger,
  SelectContent,
  SelectLabel,
  SelectItem,
  SelectSeparator,
} from "@/components/ui/select"

#Examples

Default Select

A basic select with simple options

Select with Groups

Select with grouped and labeled options

Select with Indicator

Select items with a check indicator for the selected item

Controlled Select

Select with controlled value and disabled option

Selected: None

#API Reference

PropTypeDefaultDescription
valuestringThe controlled selected value.
defaultValuestringThe initially selected value when uncontrolled.
onValueChange(value: string) => voidCallback fired when selection changes.
SelectContent.portalbooleantrueWhether to render the dropdown in a portal. Set to false when used inside a Dialog or Drawer to keep it within the modal focus trap.
SelectContent.position'item-aligned' | 'popper''popper'Controls popup positioning strategy.
SelectContent.sideOffsetnumber4Distance between trigger and popup.
SelectItem.showIndicatorbooleanfalseShows a selection indicator icon for selected items.
SelectItem.indicatorPosition'left' | 'right''left'Positions the selection indicator.