Skip to main content

Checkbox

Checkbox

Checkboxes allow users to complete tasks that involve making choices such as selecting options, or switching settings on or off. Using the onChange function will enable you to call a function when the state value changes, so basically whenever the user is tapping the Checkbox.

Usage

Imports:

import { Checkbox } from 'galio-framework';

Checkbox

Basic examples:

<Checkbox color="primary" label="Primary Checkbox" />
<Checkbox color="info" label="Info Checkbox" />
<Checkbox color="error" label="Error Checkbox" />
<Checkbox color="warning" label="Warning Checkbox" />
<Checkbox color="success" label="Success Checkbox" />

Checkbox

Advanced examples:

<Checkbox color="primary" flexDirection="row-reverse" label="row-reverse checkbox" />
<Checkbox color="info" initialValue={true} label="initialValue set to true" />
<Checkbox color="error" initialValue={true} label="different icon" iconFamily="font-awesome" iconName="plane" />
<Checkbox color="warning" labelStyle={{ color: '#FF9C09' }} label="labelStyle used here" />
<Checkbox color="success" image="https://images.unsplash.com/photo-1569780655478-ecffea4c165c?ixlib=rb-1.2.1" flexDirection="column-reverse"/>

Modern usage with hooks:

const [isChecked, setIsChecked] = useState(false);

<Checkbox
color="warning"
value={isChecked}
onChange={setIsChecked}
label="onChange is here"
/>

Props

PropTypeDefaultDescription
labelstringnullCheckbox label text
colorstring'primary'Checkbox color
valueboolfalseControlled checkbox value
onChangefunctionnullCallback when checkbox state changes
initialValueboolfalseInitial checkbox value
disabledboolfalseDisables the checkbox
flexDirectionstring'row'Layout direction: 'row', 'row-reverse', 'column', 'column-reverse'
iconNamestringnullCustom icon name
iconFamilystringnullCustom icon family
imagestringnullCustom image URL
checkboxStyleobjectnullCustom checkbox styles
labelStyleobjectnullCustom label styles
containerStyleobjectnullCustom container styles
styleobjectnullCustom styles