Forms
CheckBox
Free3.5 KB gzippedA checkbox with a label and an optional description. It is a real native <input type="checkbox"> (visually hidden but focusable) layered under a custom box, so keyboard, form submission, and screen readers work natively. Works standalone, inside Field, and as an option in CheckBoxGroup.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Space · Full report
Import
import { CheckBox, CheckBoxGroup } from "@vjdesigns/vjdesigns-ui";
Importing only CheckBox adds about 3.5 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
Clicking the label toggles the box. description is linked to it with aria-describedby.
import { CheckBox, Stack } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<Stack gap={4}>
<CheckBox label="Email me product updates" description="About once a month. Unsubscribe anytime." />
<CheckBox label="Remember this device" defaultChecked />
</Stack>
);
}
Select all
selectAll on a CheckBoxGroup adds a parent box that checks or clears every enabled option, and shows the mixed state when only some are checked. It lists the options in aria-controls, so screen readers announce that they belong to it.
import { useState } from "react";
import { CheckBox, CheckBoxGroup } from "@vjdesigns/vjdesigns-ui";
export function SelectAll() {
const [teams, setTeams] = useState(["design"]);
return (
<CheckBoxGroup label="Teams to notify" selectAll="All teams" value={teams} onValueChange={setTeams}>
<CheckBox value="design" label="Design" />
<CheckBox value="engineering" label="Engineering" />
<CheckBox value="marketing" label="Marketing" />
<CheckBox value="legal" label="Legal (read only)" disabled />
</CheckBoxGroup>
);
}
Group
CheckBoxGroup manages several boxes as one string[] value, with a group label.
import { useState } from "react";
import { CheckBox, CheckBoxGroup } from "@vjdesigns/vjdesigns-ui";
export function Group() {
const [toppings, setToppings] = useState(["cheese"]);
return (
<CheckBoxGroup
label="Toppings"
description={`Selected: ${toppings.join(", ") || "none"}`}
value={toppings}
onValueChange={setToppings}
>
<CheckBox value="cheese" label="Cheese" />
<CheckBox value="peppers" label="Peppers" />
<CheckBox value="olives" label="Olives" />
</CheckBoxGroup>
);
}
States
import { CheckBox, Stack } from "@vjdesigns/vjdesigns-ui";
export function States() {
return (
<Stack gap={4}>
<CheckBox label="Disabled" disabled />
<CheckBox label="Disabled and checked" disabled defaultChecked />
<CheckBox label="Read only" readOnly defaultChecked />
<CheckBox label="I accept the terms" invalid description="You need to accept the terms to continue." />
</Stack>
);
}
Accessibility
CheckBoxGroup groups the boxes under one label, so screen readers announce the group name before each box. A box's description is linked with aria-describedby, and invalid marks every box aria-invalid until one is chosen.
import { useState } from "react";
import { CheckBox, CheckBoxGroup } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
const [channels, setChannels] = useState<string[]>([]);
return (
<CheckBoxGroup
label="Notifications"
description="Pick at least one way to hear from us."
value={channels}
onValueChange={setChannels}
invalid={channels.length === 0}
>
<CheckBox value="email" label="Email" description="A daily summary." />
<CheckBox value="sms" label="Text message" description="Only urgent alerts." />
<CheckBox value="push" label="Push notification" />
</CheckBoxGroup>
);
}
Translated
Checkboxes have no built-in words, so translating them means translating your labels. The LocaleProvider still sets lang="ja", so screen readers pronounce them in Japanese.
import {
CheckBox,
CheckBoxGroup,
LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import ja from "@vjdesigns/vjdesigns-ui/locales/ja";
export function Translated() {
return (
<LocaleProvider locale="ja" messages={ja}>
<CheckBoxGroup label="通知方法" defaultValue={["email"]}>
<CheckBox value="email" label="メール" description="毎日のまとめ" />
<CheckBox value="sms" label="SMS" description="緊急のお知らせのみ" />
</CheckBoxGroup>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Basic
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
<Basic />
</LocaleProvider>
API reference
CheckBox
| Prop | Type | Default |
|---|---|---|
checkedChecked state (controlled). Ignored inside a | boolean | — |
defaultCheckedInitial checked state (uncontrolled). | boolean | — |
onCheckedChangeCalled with the next checked state when the user toggles the box. | (checked: boolean) => void | — |
indeterminateShows a "mixed" state (a dash) and exposes | boolean | — |
labelVisible label. Clicking it toggles the box. Without it, pass | ReactNode | — |
descriptionSupporting text below the label, linked with | ReactNode | — |
sizeBox and text size. Default | "sm""md""lg" | — |
toneFill color when checked. Default | "neutral""primary""accent""success""warning""danger""info" | — |
invalidDanger styling plus | boolean | — |
labelPositionLabel placement. | "start""end" | — |
readOnlyKeeps the box focusable and announced but prevents toggling ( | boolean | — |
valueForm value. Required inside a | string | — |
classNameClass name for the root element (the input receives every other prop). | string | — |
Also accepts native <input> attributes, plus className, style and ref.
CheckBoxGroup
A labelled set of checkboxes sharing one string[] value. Renders role="group" labelled by its own label, by a surrounding Fieldset's legend, or by aria-label/aria-labelledby.
| Prop | Type | Default |
|---|---|---|
valueChecked option values (controlled). | string[] | — |
defaultValueInitially checked option values (uncontrolled). | string[] | — |
onValueChangeCalled with the full list of checked values whenever an option is toggled. | (value: string[]) => void | — |
nameForm field name applied to every option. | string | — |
orientationStack options vertically (default) or in a wrapping row. | "horizontal""vertical" | — |
sizeSize for every option. Inherits from | "sm""md""lg" | — |
toneChecked fill color for every option. | "neutral""primary""accent""success""warning""danger""info" | — |
disabledDisable every option. Inherits from | boolean | — |
readOnlyMake every option read-only. Inherits from | boolean | — |
invalidDanger styling and | boolean | — |
labelVisible group label for standalone use. Inside a | ReactNode | — |
descriptionSupporting text below the group label, linked with | ReactNode | — |
selectAllNew in 3.4.0Label of a parent "select all" box above the options (for example "All toppings"). It checks or clears every enabled option and shows a mixed state when only some are checked. The options are wrapped in a nested group named by this label, and the box lists them in | ReactNode | — |
children
| ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
CheckBox 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 |
|---|---|
| Space | Checks or clears the box. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
<input type="checkbox"> | checkbox | aria-checked="mixed" when indeterminate, aria-invalid, aria-describedby → hint and error |
CheckBoxGroup | group | aria-labelledby → its label |
selectAll box | checkbox | aria-checked="mixed" when some are checked, aria-controls → each option |
Options under selectAll | group | aria-labelledby → the select-all label |
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) |