Checkbox
The <Checkbox/>
component allows to select or deselect options in a form. It provides a customizable checkbox input with various options.
- Usage
- Props
Import
import { Checkbox } from "matro-ui";
Checkbox
: Checkbox input
Usage
Loading...
Live Editor
<Checkbox>Checkbox</Checkbox>
Disabled Checkbox
Loading...
Live Editor
<Stack style={{gap: 20}}> <Checkbox disabled> Checkbox </Checkbox> <Checkbox disabled checked> Checkbox </Checkbox> </Stack>
Checkbox sizes
Pass the font-size
to change the size of the Checkbox. Values can be either px
, em
, rem
or %
.
Loading...
Live Editor
<Stack style={{gap: 20, alignItems: "flex-end"}}> <Checkbox style={{fontSize: "10px"}} checked> Checkbox </Checkbox> <Checkbox style={{fontSize: "14px"}} checked> Checkbox </Checkbox> <Checkbox style={{fontSize: "1.6rem"}} checked> Checkbox </Checkbox> </Stack>
Checkbox with custom color
You can override the color scheme of the Checkbox to any color by providing the css variable --bg
.
Loading...
Live Editor
<Stack style={{gap: 20, alignItems: "flex-end"}}> <Checkbox style={{"--bg": "red"}} checked> Checkbox </Checkbox> <Checkbox style={{"--bg": "#48b07d"}} checked> Checkbox </Checkbox> <Checkbox style={{"--bg": "#4848d7"}} checked> Checkbox </Checkbox> </Stack>
Checkbox as toggle
Pass the toggle
prop to change the view of the Checkbox.
Loading...
Live Editor
<Stack style={{gap: 20, alignItems: "flex-end"}}> <Checkbox style={{fontSize: "10px"}} checked toggle> Checkbox </Checkbox> <Checkbox style={{fontSize: "14px"}} checked toggle> Checkbox </Checkbox> <Checkbox style={{fontSize: "1.6rem", "--bg": "#48b07d"}} checked toggle> Checkbox </Checkbox> </Stack>
Toggle Component
Alternatively, you can use the
component. It wraps <Toggle/>
Checkbox
and pass all props to it.
Loading...
Live Editor
<Toggle style={{fontSize: "1.1rem"}} checked toggle> Toggle </Toggle>
Props
name
DescriptionThe name attribute of the checkbox.
Typestring
value
DescriptionThe value of the checkbox.
Typeboolean
onChange
DescriptionCallback function triggered when the checkbox value changes.
Typefunction
checked
DescriptionIndicates whether the checkbox is checked.
Typeboolean
toggle
DescriptionChanges checkbox view to toggle if true.
Typeboolean
linear
DescriptionSets linear type of animation if true.
Typeboolean