ValyroUI English version

Checkbox Group

Флажки с общей подписью, подсказкой, ошибкой и обязательностью. Бесплатно, MIT · Формы и ввод › Флажки и ползунки

Установка

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';

Пропсы

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.

Составные части

CheckboxGroup.Item (CheckboxGroupItem)

Похожие компоненты

  • Checkbox — Флажки
  • Radio Group — Выбор одного варианта
  • Switch — Переключатель
  • Slider — Ползунок
  • Histogram Range — Диапазон цен с гистограммой, двумя ползунками и полями
  • Rating Input — Оценка звёздами
  • Text Input — Текстовые поля
  • Textarea — Многострочный ввод
  • Search Input — Поисковая строка
  • Mentions Input — Текст с @упоминаниями и #тегами, асинхронные подсказки
  • Tags Input — Ввод тегов
  • Select — Выбор из списка

Назад: Checkbox · Далее: Radio Group · Весь раздел «Формы и ввод»