Select
A raised pill trigger that presses down while its puffy menu is open. Pick an option and a heart flies from it back to the trigger, which wobbles as it lands.
Installation
❯ npx shadcn@latest add https://yan.moe/r/select.jsonUsage
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"<Select>
<SelectTrigger className="w-56">
<SelectValue placeholder="Pick a flavour" />
</SelectTrigger>
<SelectContent>
<SelectItem value="sakura">Sakura</SelectItem>
<SelectItem value="matcha">Matcha</SelectItem>
</SelectContent>
</Select>Group options with SelectGroup, SelectLabel and SelectSeparator, as in the demo above.
Accessibility
- Built on Radix Select: arrow keys, typeahead, Home/End and Escape all work, and focus returns to the trigger.
- Give the trigger an
aria-labelwhen there is no visible label. - With
prefers-reduced-motion: reduce, the menu appears without the bounce and no heart flies.
API
| Prop | Type | Default |
|---|---|---|
intensitySet on Select. kawaii: the menu pops and a heart flies back to the trigger. subtle: the menu fades. off: it just appears. | "kawaii" | "subtle" | "off" | "kawaii" |
positionSet on SelectContent. How the menu is placed relative to the trigger. | "popper" | "item-aligned" | "popper" |
value / defaultValueSet on Select. Controlled and uncontrolled value. | string | - |
onValueChangeSet on Select. Called when an option is chosen. | (value: string) => void | - |