ValyroUI Русская версия

Checkbox Group

Checkboxes under one label, hint, error and requirement. Free, MIT · Forms and input › Checkboxes and sliders

Native checkboxes in a named group with one label, description, error and "at least one" requirement, as React Aria's CheckboxGroup. Inside a FormField the field's label, description and error describe the group instead.

Installation

npx valyro-cli@latest add checkbox-group
npx shadcn@latest add https://valyro.xyz/r/checkbox-group.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { CheckboxGroup } from 'valyro-ui';

Props

PropTypeDefault
optionsCheckboxGroupOption[]Checkboxes in order, each with a label and an optional description. Or compose them as children: CheckboxGroup.Item.
childrenReactNodeThe compound form instead of options: CheckboxGroup.Item elements.
valuestring[]Checked values, in the order they were checked.
defaultValuestring[]Initial value when uncontrolled.
onValueChange(value: string[]) => voidCalled with the new value when it changes.
namestringName of the checkboxes: each checked one submits its value under it.
labelReactNodeVisible name above the checkboxes, linked to the group. Outside a FormField a group needs a name (this, or an aria-label / aria-labelledby), or a screen reader reads the checkboxes with no question.
descriptionReactNodeHelper text under the checkboxes, read with the group. Hidden while error is set.
errorReactNodeError message; any truthy value marks the group invalid and replaces the description.
requiredbooleanAt least one box must be checked: a required mark, the labels.required word, and the form does not submit without one.
invalidbooleanfalseError colour and aria-invalid on every checkbox (set by error or a FormField too).
disabledbooleanfalseDisables every checkbox.
readOnlybooleanfalseThe checks show but cannot change.
orientation'vertical' | 'horizontal''vertical'Stack the checkboxes in a column or lay them out in a row.
size'sm' | 'md' | 'lg''md'Checkbox and text size.
labelsPartial<CheckboxGroupLabels>Overrides for the built-in English text; keys left out keep their defaults.

Compound parts

CheckboxGroup.Item (CheckboxGroupItem)

Related components

Previous: Checkbox · Next: Radio Group · All Forms and input