<cs-checkbox-group>
StableFormsSince 0.1

Checkbox groups wrap a set of related checkboxes or switches so they share a label, hint, and grouping semantics.

Checkboxes in a group remain independent form controls with their own name, value, and validation. The group exists to provide a shared label, hint, and accessible grouping.

Design Development Marketing

Examples

Label

Use the label attribute to give the group an accessible label. For labels that contain HTML, use the label slot instead.

Pepperoni Mushrooms Onions Peppers Sausage Extra cheese

Hint

Add a descriptive hint to a checkbox group with the hint attribute. For hints that contain HTML, use the hint slot instead.

Monday Wednesday Friday

Orientation

Checkbox groups stack vertically by default. Set the orientation attribute to horizontal to lay them out in a row.

Small Medium Large

Size

The size of grouped checkboxes and switches is determined by the checkbox group’s size attribute. Any size set on individual items will be overridden.

Option 1 Option 2 Option 1 Option 2 Option 1 Option 2 Option 1 Option 2 Option 1 Option 2

Disabled

A checkbox group itself can’t be disabled. Add the disabled attribute to individual checkboxes to disable them.

Insurance Gift wrap Express shipping Extended warranty

Switches

A checkbox group also works with switches.

Email SMS Push

Required

The required attribute adds a visual indicator to the group’s label. Because each checkbox is an independent control, the checkbox group doesn’t enforce the requirement. Set the required property on the checkbox or call its setCustomValidity() method to control validation.

I agree to the terms and conditions
Submit

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/checkbox-group/checkbox-group.js';
import './cornerstone/components/checkbox-group/checkbox-group.js';
import CsCheckboxGroup from '@cruglobal/cornerstone-components/react/checkbox-group/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The default slot where <cs-checkbox> or <cs-switch> elements are placed.
hintText that describes how to use the checkbox group. Alternatively, you can use the hint attribute.
labelThe checkbox group's label. Required for proper accessibility. Alternatively, you can use the label attribute.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
hinthintThe checkbox group's hint. If you need to display HTML, use the hint slot instead.string''
labellabelThe checkbox group's label. Required for proper accessibility. If you need to display HTML, use the label slot instead.string''
orientationorientationThe orientation in which to show grouped checkboxes.'horizontal' | 'vertical''vertical'Yes
requiredrequiredIndicates that at least one option should be selected. This only adds a visual indicator to the label. To enforce the requirement, use the required attribute on the individual checkboxes and/or their setCustomValidity() method.booleanfalseYes
sizesizeThe group's size. When present, this size will be applied to all <cs-checkbox> and <cs-switch> items inside.'xs' | 's' | 'm' | 'l' | 'xl'Yes
ssrHintssr-hintOnly required for SSR. Set to true if you're slotting in a hint element so the server-rendered markup includes the hint before the component hydrates on the client.booleanfalse
ssrLabelssr-labelOnly required for SSR. Set to true if you're slotting in a label element so the server-rendered markup includes the label before the component hydrates on the client.booleanfalse

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--gapThe gap between grouped checkboxes.0.5em

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
form-controlThe form control that wraps the label, group, and hint.::part(form-control)
form-control-inputThe element that wraps the grouped checkboxes, exposed as a role="group".::part(form-control-input)
form-control-labelThe label.::part(form-control-label)
hintThe hint's wrapper.::part(hint)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.