Checkbox Group

CheckboxGroup is a layout wrapper that arranges multiple Checkbox elements in a vertical or horizontal list with consistent spacing.

A daily digest at 8:00
Mentions and replies only
Security alerts only
tsx
import { Checkbox } from '@/components/ui/wideset/checkbox/Checkbox';
import { CheckboxGroup } from '@/components/ui/wideset/checkbox/CheckboxGroup';

<CheckboxGroup aria-label="Notification channels">
  <Checkbox label="Email" description="A daily digest at 8:00" defaultChecked />
  <Checkbox label="Push" description="Mentions and replies only" defaultChecked />
  <Checkbox label="SMS" description="Security alerts only" />
</CheckboxGroup>

Installation

pnpm dlx wideset add checkbox-group

Copies the component and any Wideset components it uses into your project.

Examples

Orientation

Vertical is the default and the safer choice: labels of any length line up and descriptions have room. Go horizontal only for two or three short labels with no descriptions. Either way the group needs a name: aria-labelledby pointing at its heading, or aria-label when there is none.

tsx
import { Checkbox } from '@/components/ui/wideset/checkbox/Checkbox';
import { CheckboxGroup } from '@/components/ui/wideset/checkbox/CheckboxGroup';

export default function CheckboxGroupOrientation() {
  return (
    <div className="gap-ws-14 flex flex-wrap items-start justify-center">
      <CheckboxGroup orientation="vertical" aria-label="Notification channels">
        <Checkbox label="Email" description="A daily digest at 8:00" defaultChecked />
        <Checkbox label="Push" description="Mentions and replies only" defaultChecked />
        <Checkbox label="SMS" description="Security alerts only" />
      </CheckboxGroup>
      <CheckboxGroup orientation="horizontal" aria-label="Alert channels">
        <Checkbox label="Email" defaultChecked />
        <Checkbox label="Push" defaultChecked />
        <Checkbox label="SMS" />
      </CheckboxGroup>
    </div>
  );
}

API reference

NameDescriptionDefault
orientation

Layout direction of the checkbox group. Defaults to `vertical`.

'horizontal''vertical'
'vertical'
Every other prop of <div> is passed through to it. See MDN: <div>.

Accessibility

  • The group already renders role="group". Name it with aria-labelledby pointing at the visible heading, or aria-label when there is none.
  • Each checkbox is its own tab stop and toggles with Space; orientation does not change that.
A daily digest at 8:00
Mentions and replies only
Security alerts only
tsx
import { Checkbox } from '@/components/ui/wideset/checkbox/Checkbox';
import { CheckboxGroup } from '@/components/ui/wideset/checkbox/CheckboxGroup';

<CheckboxGroup aria-label="Notification channels">
  <Checkbox label="Email" description="A daily digest at 8:00" defaultChecked />
  <Checkbox label="Push" description="Mentions and replies only" defaultChecked />
  <Checkbox label="SMS" description="Security alerts only" />
</CheckboxGroup>

Appearance

Orientation
Size

Content

Descriptions