Radio Group
Pick one. The old radio lets go in a puff, a heart flies across to the one you chose, and a gumdrop plops into it with a wobble and a ring of hearts. ぽとっ
Installation
❯ npx shadcn@latest add https://yan.moe/r/radio-group.jsonUsage
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"<RadioGroup defaultValue="regular">
<div className="flex items-center gap-3">
<RadioGroupItem value="small" id="small" />
<Label htmlFor="small">Small</Label>
</div>
<div className="flex items-center gap-3">
<RadioGroupItem value="regular" id="regular" />
<Label htmlFor="regular">Regular</Label>
</div>
</RadioGroup>For other bursts, pass a recipe from Effects: <RadioGroup fx={fxRecipes.stars}>.
Accessibility
- Built on Radix Radio Group: Tab reaches the group, arrow keys move and choose.
- Give the group an
aria-labeloraria-labelledby, and each radio aLabel. - With
prefers-reduced-motion: reduce, the gumdrop appears at once, with no flight and no particles.
API
| Prop | Type | Default |
|---|---|---|
intensitySet on RadioGroup. kawaii: a heart flies from the old radio, the gumdrop plops in with a ring of hearts. subtle: pop in with a few sparkles. off: it just moves. | "kawaii" | "subtle" | "off" | "kawaii" |
fxSet on RadioGroup. Overrides for the burst where the heart lands. | BurstOptions | - |
value / defaultValueSet on RadioGroup. Controlled and uncontrolled value. | string | - |
onValueChangeSet on RadioGroup. Called when a radio is chosen. | (value: string) => void | - |
orientationSet on RadioGroup. Which arrow keys move between radios. | "vertical" | "horizontal" | "vertical" |