Skip to content

CheckboxGroup

Group of checkboxes with shared state management.

Also known as: checkbox list, multi-check, multiple choice

View in Storybook

When to use

  • Selecting multiple values from a small set of options. For cards with descriptions, use CheckboxCard.
  • For a modal picker, use MultiSelect.

Import

tsx
import { CheckboxGroup } from '@vacano/ui'

Usage

tsx
const [values, setValues] = useState(['option1'])

const options = [
  { value: 'option1', label: 'Option 1' },
  { value: 'option2', label: 'Option 2' },
  { value: 'option3', label: 'Option 3' },
]

<CheckboxGroup
  options={options}
  value={values}
  onChange={setValues}
/>

With Label

tsx
<CheckboxGroup
  label="Select features"
  options={options}
  value={values}
  onChange={setValues}
/>

Disabled

tsx
<CheckboxGroup
  disabled
  options={options}
  value={['option1']}
  onChange={() => {}}
/>

Props

PropTypeDefaultDescription
optionsCheckboxGroupOption[]requiredArray of options
valuestring[]requiredSelected values
onChange(values: string[]) => voidrequiredChange handler
labelstring-Group label
variant'normal' | 'error''normal'Visual variant for all checkboxes
disabledbooleanfalseDisable all checkboxes
classNamestring-CSS class for root element
classnamesCheckboxGroupClassNames-Custom class names for inner elements
refRef<HTMLDivElement>-Ref to the root container element
data-test-idstring-Test identifier for automated testing

Option Type

tsx
type CheckboxGroupOption = {
  label: string
  value: string
}

ClassNames

KeyDescription
labelGroup label
optionsOptions container
checkboxIndividual checkbox

Released under the MIT License.