NOCTA UI

Select

A flexible select component for choosing from a list of options with multiple sizes and dark mode support

Installation

Install the Select component using the nocta-ui CLI:

Terminal
npx nocta-ui add select

Then import the components you need:

Import
import {
  Select,
  SelectTrigger,
  SelectContent,
  SelectItem,
  SelectValue,
} from '@/components/ui/select';

Basic Usage

Default Select

Sizes

Three size options are available: sm, md, and lg. The default size is md.

Disabled State

Customization

Custom Styling

The Select components accept className props for custom styling:

Custom Styling
<Select>
  <SelectTrigger className="w-full border-2 border-purple-300 focus-visible:border-purple-500">
    <SelectValue placeholder="Custom styled select" />
  </SelectTrigger>
  <SelectContent className="border-purple-300">
    <SelectItem value="option1">Option 1</SelectItem>
    <SelectItem value="option2">Option 2</SelectItem>
  </SelectContent>
</Select>

Props

Select

PropTypeDefaultDescription
valuestringControlled value
defaultValuestringDefault value for uncontrolled component
onValueChange(value: string) => voidCallback when value changes
disabledbooleanfalseDisable the select
size'sm' | 'md' | 'lg''md'Select size
childrenReact.ReactNodeSelect content

SelectTrigger

PropTypeDefaultDescription
classNamestring''Additional CSS classes
size'sm' | 'md' | 'lg'Override size from context
childrenReact.ReactNodeTrigger content

SelectContent

PropTypeDefaultDescription
classNamestring''Additional CSS classes
position'bottom' | 'top''bottom'Dropdown position
childrenReact.ReactNodeContent (SelectItems)

SelectItem

PropTypeDefaultDescription
valuestringItem value
disabledbooleanfalseDisable the item
classNamestring''Additional CSS classes
childrenReact.ReactNodeItem content

SelectValue

PropTypeDefaultDescription
placeholderstring'Select an option...'Placeholder text
classNamestring''Additional CSS classes

All components also accept their respective HTML element attributes.