Basic Usage
Checkbox UI and state management are separated so that you can swap in any form or state code you like.
Custom Layout
If you don't want to use the default label or layout style, you can just not provide children
to the Checkbox
component. However, you should think about wrapping the custom label and Checkbox
in a <label>
if it makes sense to increase the tap target of the component and allow users to toggle by pressing on the label as well.
Different States
Checkboxes support various states including disabled and indeterminate.
Custom Colors
Like other control components (i.e. Radio, Switch), you can customize the color of the Checkbox by setting the controlColor
prop.
For more advanced customization, you can also control the border shape and thickness using borderRadius
and borderWidth
, along with background
and borderColor
:
Multiple Checkboxes
For multiple checkbox scenarios, use ControlGroup with role="group"
for better accessibility and state management: