@warp-ds/elements 2.9.2-next.1 → 2.10.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/custom-elements.json +508 -145
- package/dist/docs/affix/affix.md +2 -2
- package/dist/docs/affix/styling.md +1 -0
- package/dist/docs/alert/alert.md +2 -2
- package/dist/docs/alert/styling.md +1 -0
- package/dist/docs/attention/attention.md +2 -0
- package/dist/docs/attention/styling.md +1 -0
- package/dist/docs/badge/badge.md +2 -0
- package/dist/docs/badge/styling.md +1 -0
- package/dist/docs/box/box.md +22 -40
- package/dist/docs/box/examples.md +20 -38
- package/dist/docs/box/styling.md +1 -0
- package/dist/docs/breadcrumbs/breadcrumbs.md +8 -2
- package/dist/docs/breadcrumbs/examples.md +7 -1
- package/dist/docs/breadcrumbs/styling.md +1 -0
- package/dist/docs/button/accessibility.md +42 -0
- package/dist/docs/button/api.md +63 -39
- package/dist/docs/button/button.md +395 -42
- package/dist/docs/button/examples.md +126 -0
- package/dist/docs/button/styling.md +72 -0
- package/dist/docs/button/usage.md +89 -0
- package/dist/docs/card/accessibility.md +74 -0
- package/dist/docs/card/api.md +9 -3
- package/dist/docs/card/card.md +236 -5
- package/dist/docs/card/examples.md +75 -0
- package/dist/docs/card/styling.md +1 -0
- package/dist/docs/card/usage.md +76 -0
- package/dist/docs/checkbox/api.md +128 -0
- package/dist/docs/checkbox/checkbox.md +134 -0
- package/dist/docs/checkbox-group/accessibility.md +71 -0
- package/dist/docs/checkbox-group/api.md +79 -0
- package/dist/docs/checkbox-group/checkbox-group.md +492 -0
- package/dist/docs/checkbox-group/examples.md +105 -0
- package/dist/docs/checkbox-group/styling.md +132 -0
- package/dist/docs/checkbox-group/usage.md +95 -0
- package/dist/docs/combobox/accessibility.md +71 -0
- package/dist/docs/combobox/api.md +60 -30
- package/dist/docs/combobox/combobox.md +205 -32
- package/dist/docs/combobox/examples.md +44 -0
- package/dist/docs/combobox/styling.md +1 -0
- package/dist/docs/combobox/usage.md +28 -0
- package/dist/docs/datepicker/accessibility.md +25 -0
- package/dist/docs/datepicker/api.md +22 -14
- package/dist/docs/datepicker/datepicker.md +208 -16
- package/dist/docs/datepicker/examples.md +75 -0
- package/dist/docs/datepicker/styling.md +1 -0
- package/dist/docs/datepicker/usage.md +84 -0
- package/dist/docs/expandable/api.md +20 -32
- package/dist/docs/expandable/examples.md +54 -0
- package/dist/docs/expandable/expandable.md +74 -32
- package/dist/docs/expandable/styling.md +1 -0
- package/dist/docs/icon/accessibility.md +5 -0
- package/dist/docs/icon/api.md +43 -0
- package/dist/docs/icon/examples.md +45 -0
- package/dist/docs/icon/icon.md +115 -0
- package/dist/docs/icon/styling.md +1 -0
- package/dist/docs/icon/usage.md +11 -0
- package/dist/docs/index.md +46 -0
- package/dist/docs/link/api.md +18 -22
- package/dist/docs/link/examples.md +75 -0
- package/dist/docs/link/link.md +113 -24
- package/dist/docs/link/styling.md +1 -0
- package/dist/docs/link/usage.md +18 -0
- package/dist/docs/modal/api.md +51 -0
- package/dist/docs/modal/examples.md +67 -0
- package/dist/docs/modal/modal.md +240 -0
- package/dist/docs/modal/styling.md +1 -0
- package/dist/docs/modal/usage.md +110 -0
- package/dist/docs/modal-footer/api.md +11 -0
- package/dist/docs/modal-footer/modal-footer.md +17 -0
- package/dist/docs/modal-header/api.md +42 -0
- package/dist/docs/modal-header/modal-header.md +48 -0
- package/dist/docs/page-indicator/api.md +6 -6
- package/dist/docs/page-indicator/examples.md +8 -0
- package/dist/docs/page-indicator/page-indicator.md +25 -6
- package/dist/docs/page-indicator/styling.md +1 -0
- package/dist/docs/page-indicator/usage.md +8 -0
- package/dist/docs/pagination/api.md +12 -10
- package/dist/docs/pagination/examples.md +20 -0
- package/dist/docs/pagination/pagination.md +52 -12
- package/dist/docs/pagination/styling.md +1 -0
- package/dist/docs/pagination/usage.md +18 -0
- package/dist/docs/pill/accessibility.md +2 -0
- package/dist/docs/pill/api.md +10 -26
- package/dist/docs/pill/examples.md +23 -0
- package/dist/docs/pill/pill.md +45 -28
- package/dist/docs/pill/styling.md +1 -0
- package/dist/docs/pill/usage.md +8 -0
- package/dist/docs/radio/radio.md +1 -7
- package/dist/docs/select/select.md +2 -0
- package/dist/docs/select/styling.md +1 -0
- package/dist/docs/slider/slider.md +2 -0
- package/dist/docs/slider/styling.md +1 -0
- package/dist/docs/slider-thumb/slider-thumb.md +2 -0
- package/dist/docs/slider-thumb/styling.md +1 -0
- package/dist/docs/step-indicator/step-indicator.md +2 -0
- package/dist/docs/step-indicator/styling.md +1 -0
- package/dist/docs/switch/styling.md +1 -0
- package/dist/docs/switch/switch.md +2 -0
- package/dist/docs/tabs/styling.md +1 -0
- package/dist/docs/tabs/tabs.md +2 -0
- package/dist/docs/textarea/styling.md +1 -0
- package/dist/docs/textarea/textarea.md +2 -0
- package/dist/docs/textfield/styling.md +1 -0
- package/dist/docs/textfield/textfield.md +2 -0
- package/dist/index.d.ts +950 -602
- package/dist/packages/affix/affix.hydration.test.js +1 -1
- package/dist/packages/affix/affix.js +4 -4
- package/dist/packages/affix/affix.js.map +4 -4
- package/dist/packages/alert/alert.hydration.test.js +1 -1
- package/dist/packages/alert/alert.js +3 -3
- package/dist/packages/alert/alert.js.map +3 -3
- package/dist/packages/attention/attention.hydration.test.js +1 -1
- package/dist/packages/attention/attention.js +397 -444
- package/dist/packages/attention/attention.js.map +4 -4
- package/dist/packages/attention/attention.test.js +1 -1
- package/dist/packages/badge/badge.hydration.test.js +1 -1
- package/dist/packages/box/box.hydration.test.js +1 -1
- package/dist/packages/box/box.js +1 -1
- package/dist/packages/box/box.js.map +1 -1
- package/dist/packages/breadcrumbs/breadcrumbs.hydration.test.js +3 -2
- package/dist/packages/breadcrumbs/breadcrumbs.js +4 -4
- package/dist/packages/breadcrumbs/breadcrumbs.js.map +3 -3
- package/dist/packages/button/button.d.ts +54 -37
- package/dist/packages/button/button.hydration.test.js +1 -1
- package/dist/packages/button/button.js +385 -432
- package/dist/packages/button/button.js.map +4 -4
- package/dist/packages/button/button.react.stories.d.ts +2 -2
- package/dist/packages/button/button.stories.d.ts +29 -0
- package/dist/packages/button/button.stories.js +176 -2
- package/dist/packages/button/react.d.ts +1 -1
- package/dist/packages/button/styles.d.ts +22 -1
- package/dist/packages/button/styles.js +390 -1
- package/dist/packages/card/card.d.ts +9 -6
- package/dist/packages/card/card.hydration.test.js +1 -1
- package/dist/packages/card/card.js +3 -3
- package/dist/packages/card/card.js.map +4 -4
- package/dist/packages/checkbox/checkbox.d.ts +45 -14
- package/dist/packages/checkbox/checkbox.hydration.test.js +1 -1
- package/dist/packages/checkbox/checkbox.js +3 -3
- package/dist/packages/checkbox/checkbox.js.map +3 -3
- package/dist/packages/checkbox/checkbox.react.stories.d.ts +1 -1
- package/dist/packages/checkbox/checkbox.stories.d.ts +2 -2
- package/dist/packages/checkbox/checkbox.test.js +1 -1
- package/dist/packages/checkbox/react.d.ts +2 -2
- package/dist/packages/checkbox-group/checkbox-group.a11y.test.js +1 -1
- package/dist/packages/checkbox-group/checkbox-group.d.ts +35 -8
- package/dist/packages/checkbox-group/checkbox-group.hydration.test.js +1 -1
- package/dist/packages/checkbox-group/checkbox-group.js +6 -6
- package/dist/packages/checkbox-group/checkbox-group.js.map +4 -4
- package/dist/packages/checkbox-group/react.d.ts +3 -3
- package/dist/packages/combobox/combobox.a11y.test.js +24 -0
- package/dist/packages/combobox/combobox.d.ts +65 -45
- package/dist/packages/combobox/combobox.hydration.test.js +39 -1
- package/dist/packages/combobox/combobox.js +21 -21
- package/dist/packages/combobox/combobox.js.map +4 -4
- package/dist/packages/combobox/combobox.stories.js +28 -15
- package/dist/packages/combobox/combobox.test.js +110 -0
- package/dist/packages/datepicker/DatePicker.test.js +1 -1
- package/dist/packages/datepicker/datepicker.d.ts +22 -30
- package/dist/packages/datepicker/datepicker.hydration.test.js +1 -1
- package/dist/packages/datepicker/datepicker.js +49 -49
- package/dist/packages/datepicker/datepicker.js.map +4 -4
- package/dist/packages/datepicker/datepicker.test.js +1 -1
- package/dist/packages/expandable/expandable.d.ts +11 -32
- package/dist/packages/expandable/expandable.hydration.test.js +1 -1
- package/dist/packages/expandable/expandable.js +11 -11
- package/dist/packages/expandable/expandable.js.map +3 -3
- package/dist/packages/expandable/expandable.react.stories.d.ts +2 -2
- package/dist/packages/expandable/react.d.ts +1 -1
- package/dist/packages/icon/icon.d.ts +16 -4
- package/dist/packages/icon/icon.hydration.test.js +1 -1
- package/dist/packages/icon/icon.js +2 -2
- package/dist/packages/icon/icon.js.map +3 -3
- package/dist/packages/icon/icon.react.stories.d.ts +1 -1
- package/dist/packages/icon/react.d.ts +2 -2
- package/dist/packages/link/link.d.ts +15 -16
- package/dist/packages/link/link.hydration.test.js +1 -1
- package/dist/packages/link/link.js +420 -190
- package/dist/packages/link/link.js.map +4 -4
- package/dist/packages/link/link.test.js +1 -1
- package/dist/packages/link/styles.d.ts +5 -0
- package/dist/packages/link/styles.js +80 -0
- package/dist/packages/modal/index.d.ts +4 -4
- package/dist/packages/modal/index.js +4 -4
- package/dist/packages/modal/modal.d.ts +22 -12
- package/dist/packages/modal/modal.hydration.test.js +1 -1
- package/dist/packages/modal/modal.js +5 -5
- package/dist/packages/modal/modal.js.map +3 -3
- package/dist/packages/modal/modal.react.stories.d.ts +3 -3
- package/dist/packages/modal/modal.stories.d.ts +2 -1
- package/dist/packages/modal/modal.stories.js +85 -3
- package/dist/packages/modal/react.d.ts +2 -2
- package/dist/packages/modal-footer/modal-footer.d.ts +5 -3
- package/dist/packages/modal-footer/modal-footer.js +4 -4
- package/dist/packages/modal-footer/modal-footer.js.map +3 -3
- package/dist/packages/modal-footer/react.d.ts +1 -1
- package/dist/packages/modal-header/modal-header.d.ts +21 -11
- package/dist/packages/modal-header/modal-header.js +11 -9
- package/dist/packages/modal-header/modal-header.js.map +4 -4
- package/dist/packages/modal-header/react.d.ts +2 -2
- package/dist/packages/page-indicator/page-indicator.d.ts +9 -14
- package/dist/packages/page-indicator/page-indicator.hydration.test.js +1 -1
- package/dist/packages/page-indicator/page-indicator.js +5 -5
- package/dist/packages/page-indicator/page-indicator.js.map +4 -4
- package/dist/packages/pagination/pagination.d.ts +11 -11
- package/dist/packages/pagination/pagination.hydration.test.js +1 -1
- package/dist/packages/pagination/pagination.js +4 -4
- package/dist/packages/pagination/pagination.js.map +4 -4
- package/dist/packages/pagination/pagination.test.js +1 -1
- package/dist/packages/pill/pill.d.ts +14 -29
- package/dist/packages/pill/pill.hydration.test.js +1 -1
- package/dist/packages/pill/pill.js +3 -3
- package/dist/packages/pill/pill.js.map +4 -4
- package/dist/packages/pill/pill.react.stories.d.ts +2 -2
- package/dist/packages/pill/react.d.ts +1 -1
- package/dist/packages/radio/radio.hydration.test.js +1 -1
- package/dist/packages/radio/radio.js +3 -3
- package/dist/packages/radio/radio.js.map +3 -3
- package/dist/packages/radio/radio.test.js +1 -1
- package/dist/packages/radio-group/radio-group.a11y.test.js +7 -3
- package/dist/packages/radio-group/radio-group.hydration.test.js +6 -2
- package/dist/packages/radio-group/radio-group.js +11 -11
- package/dist/packages/radio-group/radio-group.js.map +4 -4
- package/dist/packages/select/select.a11y.test.js +6 -2
- package/dist/packages/select/select.hydration.test.js +1 -1
- package/dist/packages/select/select.js +7 -7
- package/dist/packages/select/select.js.map +4 -4
- package/dist/packages/select/select.test.js +4 -2
- package/dist/packages/slider/slider.hydration.test.js +7 -2
- package/dist/packages/slider/slider.js +5 -5
- package/dist/packages/slider/slider.js.map +4 -4
- package/dist/packages/slider/slider.react.stories.js +2 -2
- package/dist/packages/slider/slider.test.js +1 -1
- package/dist/packages/slider-thumb/slider-thumb.hydration.test.js +1 -1
- package/dist/packages/slider-thumb/slider-thumb.js +20 -20
- package/dist/packages/slider-thumb/slider-thumb.js.map +4 -4
- package/dist/packages/step/step.hydration.test.js +1 -1
- package/dist/packages/step/step.js +8 -8
- package/dist/packages/step/step.js.map +4 -4
- package/dist/packages/step-indicator/step-indicator.hydration.test.js +1 -1
- package/dist/packages/switch/switch.a11y.test.js +1 -1
- package/dist/packages/switch/switch.hydration.test.js +1 -1
- package/dist/packages/switch/switch.js +1 -1
- package/dist/packages/switch/switch.js.map +1 -1
- package/dist/packages/tab/tab.hydration.test.js +1 -1
- package/dist/packages/tab/tab.js +10 -10
- package/dist/packages/tab/tab.js.map +2 -2
- package/dist/packages/tab-panel/tab-panel.hydration.test.js +1 -1
- package/dist/packages/tab-panel/tab-panel.js +3 -3
- package/dist/packages/tab-panel/tab-panel.js.map +2 -2
- package/dist/packages/tabs/tabs.a11y.test.js +2 -2
- package/dist/packages/tabs/tabs.hydration.test.js +1 -1
- package/dist/packages/tabs/tabs.js +1 -1
- package/dist/packages/tabs/tabs.js.map +2 -2
- package/dist/packages/tabs/tabs.test.js +4 -4
- package/dist/packages/textarea/textarea.hydration.test.js +1 -1
- package/dist/packages/textarea/textarea.js +4 -4
- package/dist/packages/textarea/textarea.js.map +3 -3
- package/dist/packages/textarea/textarea.test.js +1 -1
- package/dist/packages/textfield/textfield.hydration.test.js +1 -1
- package/dist/packages/textfield/textfield.js +1 -1
- package/dist/packages/textfield/textfield.js.map +1 -1
- package/dist/packages/textfield/textfield.test.js +1 -1
- package/dist/packages/toast/toast.js +6 -6
- package/dist/packages/toast/toast.js.map +4 -4
- package/dist/packages/toast/toast.stories.d.ts +1 -5
- package/dist/packages/toast/toast.stories.js +0 -17
- package/dist/packages/toast-container/toast-container.js +2 -2
- package/dist/packages/toast-container/toast-container.js.map +2 -2
- package/dist/web-types.json +509 -172
- package/eik/index.js +2536 -0
- package/package.json +18 -12
- package/dist/docs/radio/examples.md +0 -1
- package/dist/docs/radio/usage.md +0 -1
- package/dist/packages/button/styles/w-button.styles.d.ts +0 -1
- package/dist/packages/button/styles/w-button.styles.js +0 -282
- package/dist/packages/link/styles/w-link.styles.d.ts +0 -1
- package/dist/packages/link/styles/w-link.styles.js +0 -213
- /package/dist/docs/{radio → modal}/accessibility.md +0 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
# CheckboxGroup (w-checkbox-group)
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Use `w-checkbox-group` when several checkboxes share one label, help text, optional indicator, or required validation.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Checkbox lets users select one or more options. Use it for independent yes/no choices, multi-select lists, and terms or consent confirmations.
|
|
10
|
+
|
|
11
|
+
Use `w-checkbox-group` when several checkboxes share one label, help text, optional indicator, or required validation.
|
|
12
|
+
|
|
13
|
+
### Basic Checkbox
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The slotted text becomes the checkbox label.
|
|
20
|
+
|
|
21
|
+
### Checked State
|
|
22
|
+
|
|
23
|
+
Use `checked` when the checkbox should be selected by default.
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<w-checkbox name="alerts" value="email" checked>Email alerts</w-checkbox>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Listen for the `change` event when you need to react to user changes.
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<w-checkbox id="newsletter" name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
const checkbox = document.querySelector('#newsletter');
|
|
36
|
+
|
|
37
|
+
checkbox.addEventListener('change', () => {
|
|
38
|
+
console.log(checkbox.checked);
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Form Submission
|
|
44
|
+
|
|
45
|
+
`w-checkbox` is form-associated. When checked, it submits its `name` and `value` with the form. When unchecked or disabled, it submits nothing.
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<form>
|
|
49
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
50
|
+
<w-button type="submit">Submit</w-button>
|
|
51
|
+
</form>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If no `value` is set, the submitted value defaults to `on`.
|
|
55
|
+
|
|
56
|
+
### Required
|
|
57
|
+
|
|
58
|
+
Use `required` when one standalone checkbox must be checked before form submission, such as accepting terms.
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<form>
|
|
62
|
+
<w-checkbox name="terms" value="accepted" required>Accept the terms</w-checkbox>
|
|
63
|
+
<w-button type="submit">Continue</w-button>
|
|
64
|
+
</form>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
For a set of options where at least one option is required, put `required` on `w-checkbox-group` instead.
|
|
68
|
+
|
|
69
|
+
### Checkbox Group
|
|
70
|
+
|
|
71
|
+
Use `w-checkbox-group` to group related options under a shared label and help text.
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<w-checkbox-group label="Interests" help-text="Select all that apply" name="interests">
|
|
75
|
+
<w-checkbox value="housing">Housing</w-checkbox>
|
|
76
|
+
<w-checkbox value="jobs">Jobs</w-checkbox>
|
|
77
|
+
<w-checkbox value="travel">Travel</w-checkbox>
|
|
78
|
+
</w-checkbox-group>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The group name is applied to child checkboxes that do not have their own `name`.
|
|
82
|
+
|
|
83
|
+
### Indeterminate
|
|
84
|
+
|
|
85
|
+
Use `indeterminate` when a parent checkbox represents a mixed set of child selections.
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<w-checkbox name="all-notifications" indeterminate>All notifications</w-checkbox>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Indeterminate is a visual state. When the user clicks the checkbox, the indeterminate state is cleared and the checkbox becomes checked.
|
|
92
|
+
|
|
93
|
+
### Invalid
|
|
94
|
+
|
|
95
|
+
Set `invalid` when validation is managed outside the component.
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<w-checkbox name="terms" value="accepted" invalid>Accept the terms</w-checkbox>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
When possible, place clear error text near the checkbox or group so users know how to correct the error.
|
|
102
|
+
|
|
103
|
+
## Accessibility
|
|
104
|
+
|
|
105
|
+
Checkbox group renders the child checkboxes inside an element with `role="group"`. The group label is connected to the group, and help text is connected when provided.
|
|
106
|
+
|
|
107
|
+
### Provide A Group Label
|
|
108
|
+
|
|
109
|
+
Use `label` to describe the shared question or topic.
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<w-checkbox-group label="Interests" name="interests">
|
|
113
|
+
<w-checkbox value="housing">Housing</w-checkbox>
|
|
114
|
+
<w-checkbox value="jobs">Jobs</w-checkbox>
|
|
115
|
+
<w-checkbox value="travel">Travel</w-checkbox>
|
|
116
|
+
</w-checkbox-group>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The group label should not duplicate every option label. It should explain what the options are about.
|
|
120
|
+
|
|
121
|
+
### Use Help Text For Extra Context
|
|
122
|
+
|
|
123
|
+
Use `help-text` for instructions, constraints, or validation feedback.
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<w-checkbox-group label="Interests" help-text="Select all that apply" name="interests">
|
|
127
|
+
<w-checkbox value="housing">Housing</w-checkbox>
|
|
128
|
+
<w-checkbox value="jobs">Jobs</w-checkbox>
|
|
129
|
+
<w-checkbox value="travel">Travel</w-checkbox>
|
|
130
|
+
</w-checkbox-group>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Keep help text short and actionable.
|
|
134
|
+
|
|
135
|
+
### Required Groups
|
|
136
|
+
|
|
137
|
+
Use `required` on the group when at least one option must be selected.
|
|
138
|
+
|
|
139
|
+
```html
|
|
140
|
+
<w-checkbox-group label="Preferences" required help-text="Choose at least one" name="preferences">
|
|
141
|
+
<w-checkbox value="email">Email</w-checkbox>
|
|
142
|
+
<w-checkbox value="sms">SMS</w-checkbox>
|
|
143
|
+
</w-checkbox-group>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Do not put `required` on each child checkbox for a "choose at least one" requirement. That would mean every option must be selected.
|
|
147
|
+
|
|
148
|
+
### Validation Feedback
|
|
149
|
+
|
|
150
|
+
Do not rely on invalid styling alone. Provide clear help text that explains what the user needs to do.
|
|
151
|
+
|
|
152
|
+
```html
|
|
153
|
+
<w-checkbox-group label="Preferences" invalid help-text="Select at least one option" name="preferences">
|
|
154
|
+
<w-checkbox value="email">Email</w-checkbox>
|
|
155
|
+
<w-checkbox value="sms">SMS</w-checkbox>
|
|
156
|
+
</w-checkbox-group>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
When the group is invalid, the invalid state is also shared with child checkboxes for consistent styling and accessibility state.
|
|
160
|
+
|
|
161
|
+
### Checkbox Labels
|
|
162
|
+
|
|
163
|
+
Each child checkbox still needs its own clear label.
|
|
164
|
+
|
|
165
|
+
```html
|
|
166
|
+
<w-checkbox-group label="Contact preferences" name="contact">
|
|
167
|
+
<w-checkbox value="email">Email</w-checkbox>
|
|
168
|
+
<w-checkbox value="sms">SMS</w-checkbox>
|
|
169
|
+
<w-checkbox value="push">Push notifications</w-checkbox>
|
|
170
|
+
</w-checkbox-group>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Avoid option labels that only make sense visually, such as "Yes" or "This one", unless the group label gives enough context.
|
|
174
|
+
|
|
175
|
+
## Examples
|
|
176
|
+
|
|
177
|
+
### Basic
|
|
178
|
+
|
|
179
|
+
<elements-example>
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
</elements-example>
|
|
186
|
+
|
|
187
|
+
### Checked
|
|
188
|
+
|
|
189
|
+
<elements-example>
|
|
190
|
+
|
|
191
|
+
```html
|
|
192
|
+
<w-checkbox name="alerts" value="email" checked>Email alerts</w-checkbox>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
</elements-example>
|
|
196
|
+
|
|
197
|
+
### Required
|
|
198
|
+
|
|
199
|
+
<elements-example>
|
|
200
|
+
|
|
201
|
+
```html
|
|
202
|
+
<form>
|
|
203
|
+
<w-checkbox name="terms" value="accepted" required>Accept the terms</w-checkbox>
|
|
204
|
+
<w-button type="submit">Continue</w-button>
|
|
205
|
+
</form>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
</elements-example>
|
|
209
|
+
|
|
210
|
+
### Invalid
|
|
211
|
+
|
|
212
|
+
<elements-example>
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
<w-checkbox name="terms" value="accepted" invalid>Accept the terms</w-checkbox>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
</elements-example>
|
|
219
|
+
|
|
220
|
+
### Disabled
|
|
221
|
+
|
|
222
|
+
<elements-example>
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<w-checkbox name="newsletter" value="yes" disabled>Sign up for updates</w-checkbox>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
</elements-example>
|
|
229
|
+
|
|
230
|
+
### Indeterminate
|
|
231
|
+
|
|
232
|
+
<elements-example>
|
|
233
|
+
|
|
234
|
+
```html
|
|
235
|
+
<w-checkbox name="all-notifications" indeterminate>All notifications</w-checkbox>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
</elements-example>
|
|
239
|
+
|
|
240
|
+
### Checkbox Group
|
|
241
|
+
|
|
242
|
+
<elements-example>
|
|
243
|
+
|
|
244
|
+
```html
|
|
245
|
+
<w-checkbox-group label="Interests" help-text="Select all that apply" name="interests">
|
|
246
|
+
<w-checkbox value="housing">Housing</w-checkbox>
|
|
247
|
+
<w-checkbox value="jobs">Jobs</w-checkbox>
|
|
248
|
+
<w-checkbox value="travel">Travel</w-checkbox>
|
|
249
|
+
</w-checkbox-group>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
</elements-example>
|
|
253
|
+
|
|
254
|
+
### Required Checkbox Group
|
|
255
|
+
|
|
256
|
+
<elements-example>
|
|
257
|
+
|
|
258
|
+
```html
|
|
259
|
+
<w-checkbox-group label="Preferences" required help-text="Choose at least one" name="preferences">
|
|
260
|
+
<w-checkbox value="email">Email</w-checkbox>
|
|
261
|
+
<w-checkbox value="sms">SMS</w-checkbox>
|
|
262
|
+
<w-checkbox value="push">Push notifications</w-checkbox>
|
|
263
|
+
</w-checkbox-group>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
</elements-example>
|
|
267
|
+
|
|
268
|
+
### Form Associated
|
|
269
|
+
|
|
270
|
+
<elements-example>
|
|
271
|
+
|
|
272
|
+
```html
|
|
273
|
+
<form>
|
|
274
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
275
|
+
<w-button type="submit">Submit</w-button>
|
|
276
|
+
</form>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
</elements-example>
|
|
280
|
+
|
|
281
|
+
## Styling API
|
|
282
|
+
|
|
283
|
+
This section documents the supported styling hooks for `<w-checkbox>`.
|
|
284
|
+
|
|
285
|
+
Use these hooks to customize appearance without relying on internal structure or selectors.
|
|
286
|
+
|
|
287
|
+
### Parts
|
|
288
|
+
|
|
289
|
+
The checkbox exposes a small set of parts that can be targeted for last‑mile layout or typography tweaks.
|
|
290
|
+
|
|
291
|
+
| Part | Targets | Typical use |
|
|
292
|
+
|---|---|---|
|
|
293
|
+
| `base` | wrapper element | layout adjustments (spacing, alignment) |
|
|
294
|
+
| `control` | checkbox control (box) | minor alignment or sizing tweaks |
|
|
295
|
+
| `input` | native `<input type="checkbox">` | focus / outline adjustments |
|
|
296
|
+
| `label` | label content | typography tweaks |
|
|
297
|
+
|
|
298
|
+
Example:
|
|
299
|
+
|
|
300
|
+
```css
|
|
301
|
+
w-checkbox::part(label) {
|
|
302
|
+
font-weight: 600;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
w-checkbox::part(control) {
|
|
306
|
+
margin-top: 1px;
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Parts are intended as an **escape hatch**.
|
|
311
|
+
Prefer component tokens for anything state‑ or size‑related.
|
|
312
|
+
|
|
313
|
+
### Component tokens (`--w-c-checkbox-*`)
|
|
314
|
+
|
|
315
|
+
Component tokens act as inputs to the checkbox styling.
|
|
316
|
+
They can be set directly on the component or inherited from a parent container.
|
|
317
|
+
|
|
318
|
+
```css
|
|
319
|
+
.settings-panel {
|
|
320
|
+
--w-c-checkbox-gap: 12px;
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Defaults are defined internally; setting a token is always optional.
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
#### Layout & size
|
|
328
|
+
|
|
329
|
+
| Token | Purpose | Default |
|
|
330
|
+
|---|---|---|
|
|
331
|
+
| `--w-c-checkbox-gap` | space between control and label | `8px` |
|
|
332
|
+
| `--w-c-checkbox-control-size` | width/height of the control | `2rem` |
|
|
333
|
+
| `--w-c-checkbox-radius` | border radius of the control | `4px` |
|
|
334
|
+
| `--w-c-checkbox-border-width` | border width | `1px` |
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
#### Colors
|
|
338
|
+
|
|
339
|
+
| Token | Purpose | Default |
|
|
340
|
+
|---|---|---|
|
|
341
|
+
| `--w-c-checkbox-bg` | control background | theme default |
|
|
342
|
+
| `--w-c-checkbox-border-color` | control border color | theme default |
|
|
343
|
+
| `--w-c-checkbox-bg-checked` | background when checked | theme default |
|
|
344
|
+
| `--w-c-checkbox-border-color-checked` | border when checked | theme default |
|
|
345
|
+
| `--w-c-checkbox-icon-color` | icon color | theme default |
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
#### Invalid state
|
|
349
|
+
|
|
350
|
+
| Token | Purpose | Default |
|
|
351
|
+
|---|---|---|
|
|
352
|
+
| `--w-c-checkbox-border-color-invalid` | border color when invalid | theme default |
|
|
353
|
+
| `--w-c-checkbox-bg-invalid-checked` | background when invalid and checked | theme default |
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
#### Disabled state
|
|
357
|
+
|
|
358
|
+
| Token | Purpose | Default |
|
|
359
|
+
|---|---|---|
|
|
360
|
+
| `--w-c-checkbox-bg-disabled` | background when disabled | theme default |
|
|
361
|
+
| `--w-c-checkbox-border-color-disabled` | border when disabled | theme default |
|
|
362
|
+
| `--w-c-checkbox-bg-disabled-checked` | background when disabled and checked | theme default |
|
|
363
|
+
|
|
364
|
+
#### Focus
|
|
365
|
+
|
|
366
|
+
| Token | Purpose | Default |
|
|
367
|
+
|---|---|---|
|
|
368
|
+
| `--w-c-checkbox-outline-width` | focus outline width | `2px` |
|
|
369
|
+
| `--w-c-checkbox-outline-color` | focus outline color | theme default |
|
|
370
|
+
| `--w-c-checkbox-outline-offset` | focus outline offset | theme default |
|
|
371
|
+
|
|
372
|
+
#### Motion
|
|
373
|
+
|
|
374
|
+
| Token | Purpose | Default |
|
|
375
|
+
|---|---|---|
|
|
376
|
+
| `--w-c-checkbox-transition` | transition for control | `150ms cubic-bezier(0.4, 0, 0.2, 1)` |
|
|
377
|
+
|
|
378
|
+
Transitions are automatically disabled when `prefers-reduced-motion: reduce` is active.
|
|
379
|
+
|
|
380
|
+
### Examples
|
|
381
|
+
|
|
382
|
+
#### Compact checkbox
|
|
383
|
+
|
|
384
|
+
```css
|
|
385
|
+
.filters w-checkbox {
|
|
386
|
+
--w-c-checkbox-gap: 4px;
|
|
387
|
+
--w-c-checkbox-control-size: 1.6rem;
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
#### Rounded checkbox
|
|
392
|
+
|
|
393
|
+
```css
|
|
394
|
+
w-checkbox {
|
|
395
|
+
--w-c-checkbox-radius: 9999px;
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### Contextual color override (advanced)
|
|
400
|
+
|
|
401
|
+
```css
|
|
402
|
+
.danger-zone w-checkbox {
|
|
403
|
+
--w-c-checkbox-border-color-checked: red;
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Guidelines
|
|
408
|
+
|
|
409
|
+
- Prefer **component tokens** for size, spacing, and state styling
|
|
410
|
+
- Use **parts** only for small, local tweaks
|
|
411
|
+
- Avoid relying on internal class names or selectors
|
|
412
|
+
- If multiple tokens are required to achieve a look, consider whether a new variant or design token is more appropriate
|
|
413
|
+
|
|
414
|
+
## `<w-checkbox-group>` API
|
|
415
|
+
|
|
416
|
+
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
417
|
+
|
|
418
|
+
### Properties
|
|
419
|
+
|
|
420
|
+
| Name | Type | Default | Summary |
|
|
421
|
+
|-|-|-|-|
|
|
422
|
+
| help-text | `string` | `-` | Help text displayed below the checkbox group. |
|
|
423
|
+
| invalid | `boolean` | `false` | Whether the checkbox group is visually invalid. |
|
|
424
|
+
| label | `string` | `-` | The group label displayed above the checkboxes. |
|
|
425
|
+
| name | `string` | `-` | The name applied to child checkboxes when they do not provide one. |
|
|
426
|
+
| optional | `boolean` | `false` | Whether to show optional text next to the label. |
|
|
427
|
+
| required | `boolean` | `false` | Whether at least one checkbox in the group must be selected. |
|
|
428
|
+
| shadowRootOptions (JS only) | `object` | `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }` | - |
|
|
429
|
+
|
|
430
|
+
### Property Details
|
|
431
|
+
|
|
432
|
+
#### help-text
|
|
433
|
+
|
|
434
|
+
Help text displayed below the checkbox group.
|
|
435
|
+
|
|
436
|
+
Use this for supporting guidance or validation feedback. When required validation fails, the group replaces this text with the localized required message.
|
|
437
|
+
|
|
438
|
+
- Type: `string`
|
|
439
|
+
- Default: `-`
|
|
440
|
+
|
|
441
|
+
#### invalid
|
|
442
|
+
|
|
443
|
+
Whether the checkbox group is visually invalid.
|
|
444
|
+
|
|
445
|
+
Use this to show an externally managed validation error for the group. The invalid state is also shared with child checkboxes for consistent styling and accessibility state.
|
|
446
|
+
|
|
447
|
+
- Type: `boolean`
|
|
448
|
+
- Default: `false`
|
|
449
|
+
|
|
450
|
+
#### label
|
|
451
|
+
|
|
452
|
+
The group label displayed above the checkboxes.
|
|
453
|
+
|
|
454
|
+
Use this to describe the shared question or topic for the checkbox options. The label is connected to the internal group for assistive technologies.
|
|
455
|
+
|
|
456
|
+
- Type: `string`
|
|
457
|
+
- Default: `-`
|
|
458
|
+
|
|
459
|
+
#### name
|
|
460
|
+
|
|
461
|
+
The name applied to child checkboxes when they do not provide one.
|
|
462
|
+
|
|
463
|
+
Use this when the grouped checkboxes should submit values under the same form field name. Individual checkboxes can still override the group name with their own `name`.
|
|
464
|
+
|
|
465
|
+
- Type: `string`
|
|
466
|
+
- Default: `-`
|
|
467
|
+
|
|
468
|
+
#### optional
|
|
469
|
+
|
|
470
|
+
Whether to show optional text next to the label.
|
|
471
|
+
|
|
472
|
+
Use this to indicate that selecting an option from the group is not required.
|
|
473
|
+
|
|
474
|
+
- Type: `boolean`
|
|
475
|
+
- Default: `false`
|
|
476
|
+
|
|
477
|
+
#### required
|
|
478
|
+
|
|
479
|
+
Whether at least one checkbox in the group must be selected.
|
|
480
|
+
|
|
481
|
+
Required validation is managed by the group. The individual checkboxes provide the submitted form values.
|
|
482
|
+
|
|
483
|
+
- Type: `boolean`
|
|
484
|
+
- Default: `false`
|
|
485
|
+
|
|
486
|
+
#### shadowRootOptions (JS only)
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
- Type: `object`
|
|
491
|
+
- Default: `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }`
|
|
492
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
## Examples
|
|
2
|
+
|
|
3
|
+
### Basic
|
|
4
|
+
|
|
5
|
+
<elements-example>
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
</elements-example>
|
|
12
|
+
|
|
13
|
+
### Checked
|
|
14
|
+
|
|
15
|
+
<elements-example>
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<w-checkbox name="alerts" value="email" checked>Email alerts</w-checkbox>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
</elements-example>
|
|
22
|
+
|
|
23
|
+
### Required
|
|
24
|
+
|
|
25
|
+
<elements-example>
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<form>
|
|
29
|
+
<w-checkbox name="terms" value="accepted" required>Accept the terms</w-checkbox>
|
|
30
|
+
<w-button type="submit">Continue</w-button>
|
|
31
|
+
</form>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
</elements-example>
|
|
35
|
+
|
|
36
|
+
### Invalid
|
|
37
|
+
|
|
38
|
+
<elements-example>
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<w-checkbox name="terms" value="accepted" invalid>Accept the terms</w-checkbox>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
</elements-example>
|
|
45
|
+
|
|
46
|
+
### Disabled
|
|
47
|
+
|
|
48
|
+
<elements-example>
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<w-checkbox name="newsletter" value="yes" disabled>Sign up for updates</w-checkbox>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
</elements-example>
|
|
55
|
+
|
|
56
|
+
### Indeterminate
|
|
57
|
+
|
|
58
|
+
<elements-example>
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<w-checkbox name="all-notifications" indeterminate>All notifications</w-checkbox>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
</elements-example>
|
|
65
|
+
|
|
66
|
+
### Checkbox Group
|
|
67
|
+
|
|
68
|
+
<elements-example>
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<w-checkbox-group label="Interests" help-text="Select all that apply" name="interests">
|
|
72
|
+
<w-checkbox value="housing">Housing</w-checkbox>
|
|
73
|
+
<w-checkbox value="jobs">Jobs</w-checkbox>
|
|
74
|
+
<w-checkbox value="travel">Travel</w-checkbox>
|
|
75
|
+
</w-checkbox-group>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
</elements-example>
|
|
79
|
+
|
|
80
|
+
### Required Checkbox Group
|
|
81
|
+
|
|
82
|
+
<elements-example>
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<w-checkbox-group label="Preferences" required help-text="Choose at least one" name="preferences">
|
|
86
|
+
<w-checkbox value="email">Email</w-checkbox>
|
|
87
|
+
<w-checkbox value="sms">SMS</w-checkbox>
|
|
88
|
+
<w-checkbox value="push">Push notifications</w-checkbox>
|
|
89
|
+
</w-checkbox-group>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
</elements-example>
|
|
93
|
+
|
|
94
|
+
### Form Associated
|
|
95
|
+
|
|
96
|
+
<elements-example>
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<form>
|
|
100
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
101
|
+
<w-button type="submit">Submit</w-button>
|
|
102
|
+
</form>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
</elements-example>
|