Skip to main content
PROYECTOVIVIANA

Checkbox

Checkboxes allow users to select one or more items from a set, or to turn an option on or off.

Import

import { Checkbox, CheckboxGroup } from '@proyecto-viviana/solid-spectrum';

Basic Usage

A single checkbox for toggling a boolean option.

Selected: No

<Checkbox isSelected={selected()} onChange={setSelected}>
  Accept terms and conditions
</Checkbox>

Indeterminate State

The indeterminate state indicates a partial selection, commonly used in 'select all' scenarios.

<Checkbox isIndeterminate>Select all items</Checkbox>

Disabled State

Disabled checkboxes cannot be interacted with.

<Checkbox isDisabled>Disabled option</Checkbox>
<Checkbox isDisabled isSelected>Disabled selected</Checkbox>

Checkbox Group

Group multiple checkboxes with a shared label and state management.

Notification preferences

Selected: notifications

<CheckboxGroup
  label="Notification preferences"
  value={groupValues()}
  onChange={setGroupValues}
>
  <Checkbox value="email">Email notifications</Checkbox>
  <Checkbox value="sms">SMS notifications</Checkbox>
  <Checkbox value="push">Push notifications</Checkbox>
</CheckboxGroup>

Sizes

Checkboxes come in small, medium, and large sizes.

<Checkbox size="sm">Small</Checkbox>
<Checkbox size="md">Medium</Checkbox>
<Checkbox size="lg">Large</Checkbox>

Checkbox Props

Props

PropTypeDefaultDescription
isSelectedbooleanfalseWhether the checkbox is selected
defaultSelectedbooleanfalseDefault selected state (uncontrolled)
onChange(isSelected: boolean) => voidHandler called when selection changes
isIndeterminatebooleanfalseWhether the checkbox is in indeterminate state
isDisabledbooleanfalseWhether the checkbox is disabled
isReadOnlybooleanfalseWhether the checkbox is read-only
valuestringValue for the checkbox when used in a group
size'sm' | 'md' | 'lg''md'Size of the checkbox
childrenJSX.ElementLabel content

CheckboxGroup Props

Props

PropTypeDefaultDescription
labelstringGroup label for accessibility
valuestring[]Selected values (controlled)
defaultValuestring[]Default selected values (uncontrolled)
onChange(values: string[]) => voidHandler called when selection changes
isDisabledbooleanfalseWhether all checkboxes are disabled
orientation'horizontal' | 'vertical''vertical'Layout orientation
childrenJSX.ElementCheckbox components

Accessibility

  • Uses native <input type="checkbox"> for proper semantics
  • Supports keyboard toggle via Space key
  • Indeterminate state communicated via aria-checked="mixed"
  • Groups use role="group" with aria-labelledby
  • Focus ring visible only on keyboard navigation