Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Forms

CheckBox

Free3.5 KB gzipped

A 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

tsx
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.

About once a month. Unsubscribe anytime.
tsx
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.

Teams to notify
tsx
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.

Toppings
Selected: cheese
tsx
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

You need to accept the terms to continue.
tsx
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.

Notifications
Pick at least one way to hear from us.
A daily summary.
Only urgent alerts.
tsx
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.

通知方法
毎日のまとめ
緊急のお知らせのみ
tsx
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

About once a month. Unsubscribe anytime.
tsx
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

CheckBox props
PropTypeDefault
checked

Checked state (controlled). Ignored inside a CheckBoxGroup, which owns the state.

boolean—
defaultChecked

Initial checked state (uncontrolled).

boolean—
onCheckedChange

Called with the next checked state when the user toggles the box.

(checked: boolean) => void—
indeterminate

Shows a "mixed" state (a dash) and exposes aria-checked="mixed" via the native indeterminate property. Use for a parent "select all" box whose children are partly checked. Stays on until you set it to false.

boolean—
label

Visible label. Clicking it toggles the box. Without it, pass aria-label or aria-labelledby.

ReactNode—
description

Supporting text below the label, linked with aria-describedby.

ReactNode—
size

Box and text size. Default md (20px box). Inherits from Field or CheckBoxGroup.

"sm""md""lg"—
tone

Fill color when checked. Default primary. Inherits from CheckBoxGroup.

"neutral""primary""accent""success""warning""danger""info"—
invalid

Danger styling plus aria-invalid. Inherits from Field.

boolean—
labelPosition

Label placement. end (default) puts the label after the box, start before it.

"start""end"—
readOnly

Keeps the box focusable and announced but prevents toggling (aria-readonly).

boolean—
value

Form value. Required inside a CheckBoxGroup, where it identifies the option. Default "on".

string—
className

Class 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.

CheckBoxGroup props
PropTypeDefault
value

Checked option values (controlled).

string[]—
defaultValue

Initially checked option values (uncontrolled).

string[]—
onValueChange

Called with the full list of checked values whenever an option is toggled.

(value: string[]) => void—
name

Form field name applied to every option.

string—
orientation

Stack options vertically (default) or in a wrapping row.

"horizontal""vertical"—
size

Size for every option. Inherits from Field.

"sm""md""lg"—
tone

Checked fill color for every option.

"neutral""primary""accent""success""warning""danger""info"—
disabled

Disable every option. Inherits from Field.

boolean—
readOnly

Make every option read-only. Inherits from Field.

boolean—
invalid

Danger styling and aria-invalid on every option. Inherits from Field.

boolean—
label

Visible group label for standalone use. Inside a Fieldset, the legend labels the group instead.

ReactNode—
description

Supporting text below the group label, linked with aria-describedby.

ReactNode—
selectAllNew in 3.4.0

Label 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 aria-controls, so screen readers announce that they belong to it.

ReactNode—
children

CheckBox options, each with a unique value.

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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Dark mode

Score 100

36 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

Keyboard
KeyAction
SpaceChecks or clears the box.

Roles and states

Roles and states
ElementRoleStates and properties
<input type="checkbox">checkboxaria-checked="mixed" when indeterminate, aria-invalid, aria-describedby → hint and error
CheckBoxGroupgrouparia-labelledby → its label
selectAll boxcheckboxaria-checked="mixed" when some are checked, aria-controls → each option
Options under selectAllgrouparia-labelledby → the select-all label

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)