Skip to main content

Checkbox

Use cases:

  • Multi-selection forms
  • Filtering
  • Sorting
  • To-Do lists
  • Privacy and consent

Any use where the user is to give a boolean type input choice.

Example​

Default checkbox
Checkbox with slotted label
Check me!
Disabled checkbox

Declaration

<Checkbox></Checkbox>

Usage

import { Checkbox } from '@genesislcap/rapid-design-system/react';

export function MyComponent() {
const [checkboxValue, setCheckboxState] = useState(false);
const handleCheckboxChange = (event) => {
setCheckboxState(!!event.target.checked);
console.log({ checkboxValue })
};

const [disabled, setDisabled] = useState(false);

return (
<Checkbox disabled={disabled} onChange={handleCheckboxChange}>Checkbox</Checkbox>
);
}

DOM API​

Property and attribute binding examples for Genesis Component syntax. Closing tag omitted.

Attributes​

AttributeTypeUseExample
checkedbooleanThe boolean value of whether the checkbox is checked. Use the sync utility to allow for data from from the template back to the model.
<rapid-checkbox ?checked="${sync((x) => x.isSelected, 'boolean')}">
readonlybooleanConfigures the component so the user cannot alter the state via the web browser.
<rapid-checkbox readonly>
disabledbooleanSame functionality as readonly, and additionally greys out the component.
<rapid-checkbox disabled>
formstringAssociates this component to a form. Form id needs to be passed. If no Id informed, then it will be associated with the ancestor form.
<rapid-checkbox form="myForm">

Properties​

This component doesn't have any properties which are not also controlled via attributes.

Slots​

SlotUse
DefaultThe default slot for the label.
checked-indicatorThe checked-state indicator.
indicator-indicatorThe indeterminate (non-checked) indicator.

Parts​

PartUse
controlThe element representing the visual checkbox control.
labelThe label text.

Fired Events​

EventTypeUseExample
changebooleanEmits a custom change event when the checked state changes. Access the value on the event via .target.checked.
<rapid-checkbox @change="${(x) => x.myChangeHandler(event)}">

Listened events​

This component doesn't listen to any events.

Info​

Further details​

This component is an implementation of an HTML checkbox element.