Forms
Radio
Free6.1 KB gzippedA single option in a RadioGroup: a native radio (visually hidden but focusable) with a custom ring-and-dot indicator and a clickable label. ref points at the <input>. Outside a group it behaves like a plain native radio (name, checked/defaultChecked).
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Arrow keys, Space · Full report
Import
import { Radio, RadioGroup, RadioCard } from "@vjdesigns/vjdesigns-ui";
Importing only Radio adds about 6.1 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
Radios live in a RadioGroup, which handles the name, the label and arrow-key navigation.
import { Radio, RadioGroup } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<RadioGroup label="Notifications" defaultValue="mentions">
<Radio value="all" label="All new messages" />
<Radio value="mentions" label="Direct messages and mentions" />
<Radio value="none" label="Nothing" />
</RadioGroup>
);
}
Horizontal
import { Radio, RadioGroup } from "@vjdesigns/vjdesigns-ui";
export function Horizontal() {
return (
<RadioGroup label="Size" orientation="horizontal" defaultValue="m">
<Radio value="s" label="Small" />
<Radio value="m" label="Medium" />
<Radio value="l" label="Large" />
<Radio value="xl" label="X-Large" disabled />
</RadioGroup>
);
}
Cards
RadioCard turns each option into a selectable card, for choices that need more context.
import { Badge, RadioCard, RadioGroup } from "@vjdesigns/vjdesigns-ui";
export function Cards() {
return (
<div style={{ width: "100%", maxWidth: "34rem" }}>
<RadioGroup label="Plan" defaultValue="pro">
<RadioCard value="core" title="Core" description="All core components, free forever." meta="$0" />
<RadioCard
value="pro"
title="Pro"
description="Adds date pickers, data tables, the command palette and more."
meta={<Badge tone="primary">Popular</Badge>}
/>
<RadioCard value="custom" title="Custom" description="A design system built around your product." meta="Let's talk" />
</RadioGroup>
</div>
);
}
Accessibility
RadioGroup is a group of native radios: Tab enters the group at the selected option and the arrow keys move the choice. The group's label and description name and describe it, and a disabled option explains why in its own description.
import { Radio, RadioGroup } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<RadioGroup
label="Delivery speed"
description="Express orders placed before 2 p.m. ship today."
defaultValue="standard"
required
>
<Radio value="standard" label="Standard" description="3–5 business days, free" />
<Radio value="express" label="Express" description="Next business day, $12" />
<Radio value="pickup" label="Store pickup" description="Not available for this address" disabled />
</RadioGroup>
);
}
Translated
In Hebrew the group mirrors: each radio sits to the right of its label, and the text aligns right. The labels are your own text.
import { Radio, RadioGroup, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import he from "@vjdesigns/vjdesigns-ui/locales/he";
export function Translated() {
return (
<LocaleProvider locale="he" messages={he}>
<RadioGroup label="שיטת משלוח" defaultValue="regular">
<Radio value="regular" label="משלוח רגיל" description="3–5 ימי עסקים" />
<Radio value="express" label="משלוח מהיר" description="יום העסקים הבא" />
</RadioGroup>
</LocaleProvider>
);
}
API reference
Radio
| Prop | Type | Default |
|---|---|---|
valueRequiredValue submitted with the form and reported by | string | — |
labelVisible label. The whole label is clickable. Without one, pass | ReactNode | — |
descriptionSupporting text under the label, linked with | ReactNode | — |
disabledDisables this option (the group's | boolean | — |
sizeSize. Inherits the group's size. | "sm""md""lg" | "md" |
toneChecked color. Inherits the group's tone. | "neutral""primary""accent""success""warning""danger""info" | "primary" |
invalidInvalid styling. Inherits the group's state. | boolean | — |
classNameClass for the outer label element. The | string | — |
Also accepts standard HTML attributes, plus className, style and ref.
RadioGroup
A set of mutually exclusive options. Renders role="radiogroup" around real native <input type="radio"> elements that share a name, so Tab lands on the checked (or first) option, arrow keys move and select, and the value submits with a form. Works standalone (with label) or inside a Fieldset/group Field, where it picks up the legend, hint, error, invalid, required, and disabled state.
| Prop | Type | Default |
|---|---|---|
valueSelected value (controlled). Use with | string | — |
defaultValueInitially selected value (uncontrolled). Leave unset for no initial selection. | string | — |
onValueChangeCalled with the newly selected option's | (value: string) => void | — |
nameShared | string | — |
orientationLayout of the options. Horizontal options wrap onto new lines when space runs out. | "horizontal""vertical" | "vertical" |
sizeSize of every option. Falls back to a surrounding Field's size. | "sm""md""lg" | "md" |
toneColor of the checked ring and dot. | "neutral""primary""accent""success""warning""danger""info" | "primary" |
disabledDisables every option. Falls back to a surrounding Field's state. | boolean | — |
invalidMarks the group invalid: danger borders and | boolean | — |
requiredA selection is required: sets native | boolean | — |
labelVisible group label, used when the group stands alone. Ignored inside a group | ReactNode | — |
descriptionHelp text below the group label, linked with | ReactNode | — |
children
| ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
RadioCard
A large, card-style radio option. The whole card is the <label>, with a native radio underneath, so keyboard, form, and screen reader behavior match Radio. When checked, the card shows a ring and the indicator turns into a filled check (shape, not color alone).
| Prop | Type | Default |
|---|---|---|
valueRequiredValue submitted with the form and reported by | string | — |
titleRequiredCard title, in the display font. Becomes the radio's accessible name. | ReactNode | — |
descriptionSupporting text under the title, linked with | ReactNode | — |
iconDecorative icon shown in a tinted tile at the start of the header (e.g. | ReactNode | — |
mediaMedia (e.g. an | ReactNode | — |
metaPrice or meta slot, shown prominently under the description (e.g. | ReactNode | — |
childrenExtra content at the bottom of the card (e.g. a feature list). Not part of the accessible name. | ReactNode | — |
disabledDisables this option (the group's | boolean | — |
toneSelected ring and indicator color. Inherits the group's tone. | "neutral""primary""accent""success""warning""danger""info" | "primary" |
invalidInvalid styling. Inherits the group's state. | boolean | — |
classNameClass for the card (label) element. The | string | — |
Also accepts standard HTML attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Radio targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10036 passed · 0 failed · 29 not applicable · 10 to check by hand
Dark mode
Score 10036 passed · 0 failed · 29 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | Moves into the group, on the selected radio (or the first). |
| Arrow keys | Moves to and selects the next or previous radio, wrapping. |
| Space | Selects the focused radio. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
RadioGroup | radiogroup | aria-labelledby, aria-describedby, aria-required, aria-invalid |
<input type="radio"> | radio | Checked state is native; with a description, aria-labelledby → the label alone, so the description isn't read twice |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |