Checkbox Group
<wa-checkbox-group>
Checkbox groups wrap related checkboxes so they keep Web Awesome's labeling semantics while also behaving as a single aggregate form control with a shared array value.
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.
Examples
Label
Use the label attribute to give the group an accessible label. For labels that contain HTML, use the label slot instead.
Hint
Add a descriptive hint to a checkbox group with the hint attribute. For hints that contain HTML, use the hint slot instead.
Orientation
Checkbox groups stack vertically by default. Set the orientation attribute to horizontal to lay them out in a row.
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.
Disabled
A checkbox group itself can't be disabled. Add the disabled attribute to individual checkboxes to disable them.
Switches
A checkbox group also works with switches.
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.
Yoummday Extensions
The Yoummday checkbox group keeps Web Awesome's labeling and layout semantics, but it also behaves as a single form
control with an aggregated value array. This matches the legacy Yoummday behavior that treated a group of
checkboxes as one required field and one submission value source.
Aggregate Value And Form Submission
When you set name on the group, every selected child value is submitted under that one field name.
Migrated Naming
Legacy alignment becomes orientation, and help-text becomes hint. Group-level sl-input and sl-change
become native input and change.
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://cdn.yoummday.com/packages/@yoummday/webawesome/0.5.1/dist/components/checkbox-group/checkbox-group.js';
After installing Web Awesome via npm, import this component:
import '@yoummday/webawesome/dist/components/checkbox-group/checkbox-group.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/checkbox-group/checkbox-group.js';
To import this component for React 18 or below, use the following code:
import YoummdayCheckboxGroup from '@yoummday/webawesome/dist/react/checkbox-group/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | The default slot where <wa-checkbox> or <wa-switch> elements are placed. |
hint
|
Text that describes how to use the checkbox group. Alternatively, you can use the hint attribute. |
label
|
The checkbox group's label. Required for proper accessibility. Alternatively, you can use the label attribute. |
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects |
|---|---|---|
defaultValue |
The default value used when resetting a parent form.
Type
string[]
Default
[]
|
|
disableddisabled |
Disables the group and all child toggles.
Type
boolean
Default
false
|
|
hinthint |
The checkbox group's hint. If you need to display HTML, use the
hint slot instead.
Type
string
Default
''
|
|
labellabel |
The checkbox group's label. Required for proper accessibility. If you need to display HTML, use the
label slot
instead.
Type
string
Default
''
|
|
namename |
The name of the group, submitted for each selected value.
Type
string | null
Default
null
|
|
orientationorientation |
The orientation in which to show grouped checkboxes.
Type
'horizontal' | 'vertical'
Default
'vertical'
|
|
requiredrequired |
Indicates 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.
Type
boolean
Default
false
|
|
sizesize |
The group's size. When present, this size will be applied to all
<wa-checkbox> and <wa-switch> items inside.
Type
'xs' | 's' | 'm' | 'l' | 'xl' | 'small' | 'medium' | 'large'
|
|
value |
The group's current selected values.
Type
string[]
Default
[]
|
|
withHintwith-hint |
Only 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.
Type
boolean
Default
false
|
|
withLabelwith-label |
Only 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.
Type
boolean
Default
false
|
Events
Learn more about events.
| Name | Description |
|---|---|
change |
Emitted when the group's aggregated value changes due to user interaction. |
input |
Emitted when the group's aggregated value changes due to user interaction. |
wa-invalid |
Emitted when the group fails constraint validation. |
CSS Custom Properties
Learn more about CSS custom properties.
| Name | Description |
|---|---|
--gap |
The gap between grouped checkboxes.
Default
0.5em
|
CSS Parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
form-control |
The form control that wraps the label, group, and hint. |
::part(form-control)
|
form-control-input |
The element that wraps the grouped checkboxes and switches. |
::part(form-control-input)
|
form-control-label |
The label's wrapper. |
::part(form-control-label)
|
hint |
The hint's wrapper. |
::part(hint)
|
items |
Alias of form-control-input, retained for migrated consumers. |
::part(items)
|
Dependencies
This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.