A radio group with roving tabindex and a traveling dot morph — the selection indicator springs from the previous radio to the new one via layoutId animation.
Dependencies
Interaction Type
Click to select. Arrow keys move and select (Up/Down vertical, Left/Right horizontal, RTL-aware). Tab enters/exits the group as a single stop.
Props
Options you can pass to customize this component.
valueControlled selected value.
defaultValueInitial value for uncontrolled usage.
onValueChangeCalled when the selected value changes.
nameForm field name applied to hidden radio inputs.
disabledDisables all items in the group.
requiredMarks the group as required for form validation.
orientationLayout direction. Determines which arrow keys navigate.
Installation
How to use
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
export function Demo() {
const [size, setSize] = useState('medium')
return (
<RadioGroup value={size} onValueChange={setSize} name="size">
<RadioGroupItem value="small">Small</RadioGroupItem>
<RadioGroupItem value="medium">Medium</RadioGroupItem>
<RadioGroupItem value="large">Large</RadioGroupItem>
</RadioGroup>
)
}Source Code
Click the code icon in the top-right corner to view the source code.
License & Usage
// No code loaded.