CheckboxGroup
The CheckboxGroup
component is a special component, designed to group a set
of Checkbox
components together. It is a useful component for grouping
related checkboxes and allowing users to select multiple options. You can also
choose whether to arrange these checkboxes horizontally or vertically.
Usage
To use the CheckboxGroup
, you’ll typically need to import both the CheckboxGroup
and Checkbox
components from the package:
Then, in your app, you can create a group of checkboxes by adding the label
and name
props to the CheckboxGroup
component and adding multiple Checkbox
components inside it. Each checkbox within the group should have a unique value to represent different options:
Disabled
Similar to the Checkbox
component, you can mark the group as disabled by passing the isDisabled
prop:
Read-only
Or, mark all the checkboxes within the group as read-only with the isReadOnly
prop:
Description
You can also add a description to the CheckboxGroup
component to provide additional information, instruction, or context about the group of checkboxes:
Styles
The CheckboxGroup
component has static classes, prefixed with .kubrick-CheckboxGroup-
. You can use these static classes to
select and customize the component and its elements.
Selector | Description |
---|---|
root | The root element of the checkbox group. |
label | The wrapper element of the group label. |
items | The wrapper element containing all the checkboxes. |
description | The wrapper element of the group description. |
Events
The CheckboxGroup
component will emit some events on user
interactions. You can handle these events by passing a function as a
callback to the following props:
Event | Description |
---|---|
onChange | Triggered when the check state changes. The callback function will receive an array of values representing the checked checkboxes. |
onFocusChange | Triggered when the input receives or loses focus. The callback function will receive a boolean indicating if the input is focused. |
You can listen to the onChange
event to handle the changes of checkboxes state within the group.
As mentioned the callback on the onChange
prop will receive an array of values representing the checked checkboxes. In the above example, if the permalink
and author
checkboxes are checked, the selection
state will be ['permalink', 'author']
.