- Docs
- Components
- Forms
Radio
One answer from a few, all in view and always answered. The group is one Tab stop.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<div role="radiogroup">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Playground
Every prop, live, and the code it takes.
Session length
Orientation
import { Radio, RadioGroup } from "@qeetrix/react";
<RadioGroup label="Session length" defaultValue="8h">
<Radio value="1h" label="1 hour" />
<Radio value="8h" label="8 hours" />
<Radio value="24h" label="24 hours" />
</RadioGroup>02
A group
One answer from a few, always answered. Arrow keys move and choose; the group is one Tab stop.
Billing cycle
<RadioGroup label="Billing cycle" defaultValue="yearly">
<Radio value="monthly" label="Monthly" description="₹2,400 a seat" />
<Radio value="yearly" label="Yearly" description="₹24,000 a seat: two months free" />
</RadioGroup>03
In a row
orientation="horizontal", for short options.
Session length
<RadioGroup label="Session length" orientation="horizontal" defaultValue="8h">
<Radio value="1h" label="1 hour" />
<Radio value="8h" label="8 hours" />
<Radio value="24h" label="24 hours" />
</RadioGroup>04
Tiles
variant="tile": for choices that need explaining, such as an application's type.
Application type
<RadioGroup label="Application type" variant="tile" columns={3} defaultValue="web">
<Radio value="web" icon={AppWindowIcon} label="Web app" description="Signs people in on a server." />
<Radio value="native" icon={SmartphoneIcon} label="Mobile app" description="iOS or Android, with PKCE." />
<Radio value="machine" icon={ServerIcon} label="Service" description="Machine to machine, no people." />
</RadioGroup>05
Controlled
Generic over its value: RadioGroup<"monthly" | "yearly">, and the page follows it.
Billing cycle
const [cycle, setCycle] = useState<"monthly" | "yearly">("yearly");
<RadioGroup<"monthly" | "yearly"> label="Billing cycle" value={cycle} onValueChange={setCycle}>
<Radio value="monthly" label="Monthly" />
<Radio value="yearly" label="Yearly" />
</RadioGroup>06
Invalid and disabled
The group's error; an option that can't be chosen, and why.
Data region
Choose where Acme's data lives.
<RadioGroup label="Data region" error="Choose where Acme's data lives.">
<Radio value="mum" label="Mumbai" />
<Radio value="hyd" label="Hyderabad" />
<Radio value="fra" label="Frankfurt" disabled description="Not on your plan." />
</RadioGroup>