@3mo/checkbox-group
v0.1.6
Published
A web component for parent checkboxes that check or clear their nested checkboxes and turn indeterminate when mixed.
Readme
Checkbox Group
A web component for parent checkboxes that check or clear their nested checkboxes and turn indeterminate when mixed.
A checkbox that selects or clears the checkboxes nested in it, and shows a dash while only some are selected.
Installation
npm install @3mo/checkbox-groupimport '@3mo/checkbox-group'Usage
<mo-checkbox-group label='Notifications' direction='vertical'>
<mo-checkbox label='Email' selected></mo-checkbox>
<mo-checkbox label='SMS'></mo-checkbox>
<mo-checkbox label='Push'></mo-checkbox>
</mo-checkbox-group>Examples
- Nested — Groups nest: each one reflects its own checkboxes, and selecting a group selects everything inside it.
- Horizontal —
direction='horizontal'lays the checkboxes out in a row. - Custom Properties —
--mo-checkbox-group-nested-marginsets how far the checkboxes are indented.
API
mo-checkbox-group
Properties
| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| direction | direction | FlexDirection | "vertical" | The direction the nested checkboxes are laid out in |
| label | label | string | "" | The label of the checkbox. |
| disabled | disabled | boolean | false | Whether the checkbox is disabled or not. |
| selected | selected | CheckboxSelection | false | Whether the checkbox is selected or not. This can be set to 'indeterminate' to show a dash instead of a check-mark. |
Events
| Name | Detail | Description |
| --- | --- | --- |
| change | CheckboxSelection | Dispatched when the selection state of the checkbox changes. |
Slots
| Name | Description | | --- | --- | | (default) | The checkboxes and groups the group selects |
CSS custom properties
| Name | Description |
| --- | --- |
| --mo-checkbox-group-nested-margin | The indentation of the nested checkboxes, 32px by default |
| --mo-checkbox-accent-color | The color of the selected box, its focus ring and its state layer |
| --mo-checkbox-disabled-color | The color of a disabled checkbox and its label |
Links
License
MIT © 3MO GmbH
