CheckboxGroup

A checkbox group with an array of selected values.

Children are Checkbox or Toggle; onChange returns an array of values. label, description, and errorMessage add a group heading, a hint, and error text. Items keep their own disabled, size, and name.

Live example

Group label

Example controls

Usage

import { Checkbox, CheckboxGroup } from '@prosazhin/pbcomponents';

<CheckboxGroup
  label='Options'
  defaultValue={['One']}
>
  {['One', 'Two', 'Three', 'Four', 'Five'].map((item) => (
    <Checkbox
      key={item}
      value={item}
    >
      {item}
    </Checkbox>
  ))}
</CheckboxGroup>;

Component API

PropType / variantsPurposeDefault
childrenCheckbox[] | Toggle[]Group items; Checkbox and Toggle can be combined. Items keep their own disabled, size and name.—
size's' | 'm's · mComponent size.—
labelReactNodeGroup heading (legend).—
descriptionReactNodeHint below the group heading.—
errorMessageReactNodeError text below the group; linked to it via aria-describedby.—
namestringShared name of the native inputs.—
disabledbooleanDisables interaction.false
valuestring[]Selected values.—
defaultValuestring[]Initial value when uncontrolled.[]
onChange(values: string[]) => voidReports the selected values.—
classNamestringClass of the root element.—

Native HTML attributes are accepted where the component renders the corresponding element. className props only affect styling.