Checkbox Group
To display a checkbox group, list two or more CheckboxGroupItem components within CheckboxGroup.
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";
export default () => ( <CheckboxGroup defaultValue={["author"]} label="Customization"> <CheckboxGroupItem value="author" label="Show author" /> <CheckboxGroupItem value="steps" label="Show step count" /> <CheckboxGroupItem value="time" label="Show creation time" /> <CheckboxGroupItem value="toc" label="Show table of contents" /> </CheckboxGroup>);Orientation
Section titled “Orientation”Display checkboxes horizontally by passing orientation="horizontal".
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";
export default () => ( <CheckboxGroup defaultValue={["reduce-motion"]} orientation="horizontal" label="Accessibility" > <CheckboxGroupItem value="high-contrast" label="High Contrast" /> <CheckboxGroupItem value="reduce-motion" label="Reduce Motion" /> </CheckboxGroup>);Disabled
Section titled “Disabled”The entire group can be disabled by using the disabled prop.
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";
export default () => ( <CheckboxGroup defaultValue={["author", "steps"]} disabled label="Customization" > <CheckboxGroupItem value="author" label="Show author" /> <CheckboxGroupItem value="steps" label="Show step count" /> <CheckboxGroupItem value="time" label="Show creation time" /> <CheckboxGroupItem value="toc" label="Show table of contents" /> </CheckboxGroup>);The disabled prop can also be used to disable a specific CheckboxGroupItem.
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";
export default () => ( <CheckboxGroup defaultValue={["author"]} label="Customization"> <CheckboxGroupItem value="author" label="Show author" /> <CheckboxGroupItem value="steps" label="Show step count" /> <CheckboxGroupItem value="time" label="Show creation time" /> <CheckboxGroupItem value="toc" label="Show table of contents" disabled /> </CheckboxGroup>);Multiple selections
Section titled “Multiple selections”Unlike RadioGroup, CheckboxGroup allows multiple items to be selected simultaneously.
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";
export default () => ( <CheckboxGroup defaultValue={["author", "steps"]} label="Customization"> <CheckboxGroupItem value="author" label="Show author" /> <CheckboxGroupItem value="steps" label="Show step count" /> <CheckboxGroupItem value="time" label="Show creation time" /> <CheckboxGroupItem value="toc" label="Show table of contents" /> </CheckboxGroup>);Help text
Section titled “Help text”Display links to each section
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";
export default () => ( <CheckboxGroup defaultValue={["author", "steps"]} label="Customization"> <CheckboxGroupItem value="author" label="Show author" /> <CheckboxGroupItem value="steps" label="Show step count" /> <CheckboxGroupItem value="time" label="Show creation time" /> <CheckboxGroupItem value="toc" label="Show table of contents" helpText="Display links to each section" /> </CheckboxGroup>);Controlled state
Section titled “Controlled state”By default, CheckboxGroup is uncontrolled, meaning it manages its own state locally. To make it controlled, set value and onValueChange.
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";import { useState } from "react";
export default () => { const [checkboxValues, setCheckboxValues] = useState(["toc"]);
return ( <CheckboxGroup value={checkboxValues} onValueChange={(values) => setCheckboxValues(values)} label="Customization" > <CheckboxGroupItem value="author" label="Show author" /> <CheckboxGroupItem value="steps" label="Show step count" /> <CheckboxGroupItem value="time" label="Show creation time" /> <CheckboxGroupItem value="toc" label="Show table of contents" /> </CheckboxGroup> );};Sizing
Section titled “Sizing”A smaller version of the checkbox group may be used by passing size="sm".
import { CheckboxGroup, CheckboxGroupItem } from "stylus-ui/CheckboxGroup";
export default () => ( <CheckboxGroup defaultValue={["time"]} size="sm" label="Customization"> <CheckboxGroupItem value="author" label="Show author" /> <CheckboxGroupItem value="steps" label="Show step count" /> <CheckboxGroupItem value="time" label="Show creation time" /> <CheckboxGroupItem value="toc" label="Show table of contents" /> </CheckboxGroup>);Keyboard Controls
Section titled “Keyboard Controls”| Key | Description |
|---|---|
| Tab | Move focus into and out of the checkbox group |
| ↑ ↓ | Navigate between options (vertical layout) |
| ← → | Navigate between options (horizontal layout) |
| Space | Toggle the focused option |
| Home | Jump to first option |
| End | Jump to last option |
API Reference
Section titled “API Reference”CheckboxGroup
Section titled “CheckboxGroup”A set of checkable buttons where multiple options can be selected at a time.
defaultValue
Initial selected values when uncontrolled.
disabled
Disable all checkboxes in the group.
label
Label shown above the group.
loop
Whether keyboard focus loops within the group.
name
Name for the group (used for form submission).
onValueChange
Called when the selection changes.
orientation
Layout direction: vertical (stacked) or horizontal (row).
required
Require at least one selection.
size
Size of each checkbox: default or sm.
theme
Visual theme for the group and items.
value
Controlled selected values (array of option values).
CheckboxGroupItem
Section titled “CheckboxGroupItem”An individual checkbox item within a CheckboxGroup. Must be rendered inside CheckboxGroup.
value
Value for this option when selected (included in group value array).
align
Position of the label relative to the box: left or right.
asChild
checked
children
Additional content below the label.
defaultChecked
helpText
Helper text shown below the checkbox.
label
Label shown beside the checkbox.
onCheckedChange
required
size
Override group size for this item.
theme
Override group theme for this item.