Forms
Radio group
One choice out of a few, each with room for a description. Arrow keys move the choice.
Forms
One choice out of a few, each with room for a description. Arrow keys move the choice.
Change the props on the right. The radio group and its code follow.
Export as
import { Label } from 'omuk-ui/label';
import { RadioGroup, RadioGroupItem } from 'omuk-ui/radio-group';
<div className="flex flex-col gap-3">
<p id="format" className="text-sm font-medium">Export as</p>
<RadioGroup aria-labelledby="format" defaultValue="dotenv">
<div className="flex items-center gap-2">
<RadioGroupItem id="dotenv" value="dotenv" />
<Label htmlFor="dotenv" className="font-normal">.env file</Label>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem id="json" value="json" />
<Label htmlFor="json" className="font-normal">JSON</Label>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem id="yaml" value="yaml" />
<Label htmlFor="yaml" className="font-normal">YAML</Label>
</div>
</RadioGroup>
</div>Each RadioGroupItem has a value and a Label linked with htmlFor. Name the group with aria-labelledby or aria-label. Tab to the group, then use the arrow keys.
Export as
A horizontal Field for each choice puts the radio on the first line of its label, with the description below. A disabled choice stays in view and is skipped by the arrow keys.
The group is a grid with gap 3. A flex class lays short choices out in a row; the arrow keys work the same.
RadioGroup is the root and takes the props of a <div>; RadioGroupItem takes the props of a <button>.