JGuang

CheckboxList

CheckboxList · Astryx

Preview
npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

CheckboxList

CheckboxList shows a small group of checkboxes so users can turn several options on or off at once. Place it in settings pages, filter panels, or forms where every choice should be visible without scrolling. For a single standalone checkbox (like "I agree to the terms"), use CheckboxInput instead. If only one option can be picked, use RadioList. If the list is long enough to need searching or scrolling, use MultiSelector instead.

Installation

npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

Requires React 19+, base CSS and a Theme provider. See Setup.

Checkbox List

CheckboxList shows a small group of checkboxes so users can turn several options on or off at once. Place it in settings pages, filter panels, or forms where every choice should be visible without scrolling. For a single standalone checkbox (like "I agree to the terms"), use CheckboxInput instead. If only one option can be picked, use RadioList. If the list is long enough to need searching or scrolling, use MultiSelector instead.

PropTypeDefaultDescription
label *stringLabel text for the checkbox group (always rendered for accessibility).
children *ReactNodeCheckboxListItem elements.
valuestring[]The currently selected values (collection mode).
onChange(values: string[]) => voidCallback fired when the selected values change.
changeAction(values: string[]) => void | Promise<void>Async action on change with optimistic updates. While the promise is pending, the toggled item shows a spinner inside its checkbox and is marked aria-busy.
isLabelHiddenbooleanfalseWhether to visually hide the label.
descriptionstringDescription text displayed below the label.
density'compact' | 'balanced' | 'spacious''balanced'Spacing density for list items.
hasDividersbooleanfalseWhether to show dividers between items.
isDisabledbooleanfalseWhether all checkbox items are disabled.
disabledMessagestringExplains why the group is disabled. Applies to the whole-group disabled state (isDisabled), not per item. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the checkboxes focusable via aria-disabled (toggling stays blocked). Use this instead of wrapping a disabled CheckboxList in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.
isReadOnlybooleanfalseWhether all checkbox items are read-only. Displays the current state at full opacity but prevents interaction. Unlike isDisabled, read-only checkboxes are not visually dimmed.
status{type: 'warning' | 'error' | 'success', message?: string}Status indicator ({ type, message }).
widthSizeValueWidth of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.
containerXstyleStyleXStylesStyleX styles for the field container (label, control, and status together). No effect inside InputGroup (style the InputGroup instead) or in a horizontal-labels FormLayout. Root xstyle, className, and style are not accepted.
containerClassNamestringClass name for the field container. Same targeting as containerXstyle.
containerStyleCSSPropertiesInline styles for the field container. Same targeting as containerXstyle.
controlXstyleStyleXStylesStyleX styles for the visual control box: the element that paints the border and background and holds icons and end controls. Never the native input.
controlClassNamestringClass name for the visual control box.
controlStyleCSSPropertiesInline styles for the visual control box.

Usage guidance

  • Keep the list short: three to seven options is the sweet spot. Beyond that, switch to MultiSelector which adds search and scrolling.
  • Turn on dividers (hasDividers) when items have helper text underneath; without them the labels and descriptions blur together.
  • Write a group label that says what the choices represent: "Export formats" tells users more than "Options".
  • Avoid: Show a CheckboxList when the user can only pick one thing; that is what RadioList is for.
  • Avoid: Put buttons or links inside the trailing slot (endContent); the whole row is already tappable, so a nested button creates two competing click targets.
  • Avoid: Wrap a disabled CheckboxList in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.

Theming API

{
  "targets": [
    {
      "className": "astryx-checkbox-list"
    }
  ]
}

CheckboxListItem

Anatomy

  • Group: Container for the labeled checkbox group.
  • Group label: Text identifying what the checkbox options represent.
  • Description: Helper text below the group label.
  • Options list: List containing the available checkbox options.
  • Option row: Selectable row containing one option.
  • Checkbox: Selection indicator for an option.
  • Option label: Primary content identifying an option.
  • Option description: Secondary text below an option label.
  • End content: Caller-provided content at the end of an option row.
  • Spinner: Loading indicator shown inside the pending checkbox.
  • Status message: Error, warning, or success message below the group.

Checkbox List Item

Individual checkbox item with label, description, and end content slot. Works in collection mode (inside a CheckboxList with a value array) or standalone mode (inside List, or inside a CheckboxList without value, such as a select-all item).

PropTypeDefaultDescription
label *ReactNodePrimary text label for the item. Rich labels may contain links or buttons, which keep their own behavior without toggling the item. A ReactNode label names the checkbox from its visible text; pass aria-label only when that text is absent, or include all visible label words in the override.
aria-labelstringPlain-text accessible name for the checkbox, replacing the one derived from label. Applied to the checkbox control. Use it when a rich label has no visible text; otherwise the value must retain every visible label word.
valuestringIdentity key. Required when the parent CheckboxList has a value array; the item throws without it there.
descriptionReactNodeSecondary content below the label. String or ReactNode. Exposed as the checkbox's accessible description through aria-describedby, so assistive technology can tell it is the explanation for that choice.
endContentReactNodeContent rendered after the label area.
isDisabledbooleanfalseWhether this individual item is disabled.
isLoadingbooleanfalseWhether this item is loading. Shows a spinner inside the checkbox and blocks interaction on this item. In collection mode, the toggled item also shows this automatically while the parent changeAction is pending.
isCheckedboolean | 'indeterminate'Direct checked state in standalone mode: inside List, or inside a CheckboxList without value (for example, a select-all item). Ignored when the parent CheckboxList has a value array.
onCheck(checked: boolean) => voidDirect check handler in standalone mode: inside List, or inside a CheckboxList without value. Ignored when the parent CheckboxList has a value array; that list's onChange receives the change.

Rich label with an overriding aria-label

<CheckboxListItem
  label={<span>Pro plan <Badge label="Recommended" /></span>}
  aria-label="Pro plan Recommended option"
  value="pro"
/>

Examples

  • Checkbox List Item: Checkbox list items with labels, descriptions, and different states including disabled.
  • Checkbox List:
  • CheckboxListItem — Basic: Checkbox items with labels and descriptions inside a controlled CheckboxList. Use for multi-select option groups like notification preferences.
  • CheckboxList — Select All With Indeterminate: A "select all" toggle at the top of a checkbox list that switches to an indeterminate dash when only some items are checked, useful for bulk actions like exporting documents or assigning permissions where users often want everything at once.
  • CheckboxList — With End Content: Badges in the trailing slot show contextual info, like a price or status, next to each option without cluttering the label, so users can compare choices at a glance.