Select
Single-choice selector primitive built on Radix Select.
npx shadcn@latest add @aavya/ui-select
One-time setup — add the @aavya registry to your components.json so branded dependencies resolve to Aavya (not stock shadcn):
"registries": { "@aavya": "https://registry-dev.aavya.com/r/{name}.json" }Or install by full URL: npx shadcn@latest add https://registry-dev.aavya.com/r/ui-select.json
Role
| Part | Prop | Type | Default |
|---|---|---|---|
| SelectTrigger | size? | 'sm' | 'default' | 'default' |
Select forwards remaining props to SelectPrimitive.Root props.
Do
- Use Select to pick one value from a known list; give it a clear placeholder.
- Label the trigger with a visible <label> or an aria-label.
- Keep option text concise and scannable.
Don’t
- Don't use Select for actions — use a Dropdown Menu or buttons.
- Don't use it for very long lists or free text — use a searchable combobox or input.
- Don't leave the trigger unlabelled.
Role
listbox / option with a combobox-style trigger (handled by Radix).
Keyboard
Enter/Space open; arrow keys move; typeahead jumps; Enter selects; Esc closes. (handled)
Screen reader
Announces the selected value and the option list. Provide an accessible label for the trigger — you provide this.
Focus
Focus returns to the trigger on close. (handled)
Gotcha
The trigger has no visible <label> by default — associate one (htmlFor/id) or pass aria-label.
import { Select } from '@/components/ui/select'
export default function Example() {
return (
<div className="p-6">
<Select />
</div>
)
}
'use client'
import * as React from 'react'
import * as SelectPrimitive from '@radix-ui/react-select'
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react'
import { cn } from '@/lib/utils'
function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {
return <SelectPrimitive.Root data-slot='select' {...props} />
}
function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>) {
return <SelectPrimitive.Group data-slot='select-group' {...props} />
}
function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>) {
return <SelectPrimitive.Value data-slot='select-value' {...props} />
}
function SelectTrigger({
className,
size = 'default',
children,
...props
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
size?: 'sm' | 'default'
}) {
return (
<SelectPrimitive.Trigger
data-slot='select-trigger'
data-size={size}
className={cn(
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowr