<Checkbox size="md" isInvalid={false} isDisabled={false}><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Label</CheckboxLabel></Checkbox>
import { Checkbox } from '@gluestack-ui/themed';
export default () => (<CheckboxGroup><Checkbox><CheckboxIndicator><CheckboxIcon /></CheckboxIndicator><CheckboxLabel /></Checkbox></CheckboxGroup>)
Prop | Type | Default | Description |
---|---|---|---|
value | string | - | The value to be used in the checkbox input. This is the value that will be returned on form submission. |
onChange | (value: boolean) => void | - | Function called when the state of the checkbox changes. |
defaultIsChecked | bool | false | If true, the checkbox will be initially checked. |
isChecked | bool | false | When true, the checkbox will be checked. You'll need to pass onChange to update it's value (since it's now controlled). |
isDisabled | bool | false | To manually set disable to the checkbox. |
isInvalid | bool | false | To manually set invalid to the checkbox. |
isReadOnly | bool | false | To manually set read-only to the checkbox. |
isHovered | bool | false | To manually set hover to the checkbox. |
isFocusVisible | bool | false | To manually set focus visible state to the checkbox. |
isIndeterminate | bool | false | To manually set indeterminate to the checkbox. |
Sx Prop | Description |
---|---|
_text | Prop to style CheckboxLabel Component |
_icon | Prop to style CheckboxIcon Component |
_indicator | Prop to style CheckboxIndicator Component |
Prop | Type | Default | Description |
---|---|---|---|
value | string[] | - | The value of the checkbox group. |
onChange | (values: Array<string>) => void | - | The callback fired when any children Checkbox is checked or unchecked. |
isDisabled | bool | false | To manually set disable to the checkbox. |
isInvalid | bool | false | To manually set invalid to the checkbox. |
isReadOnly | bool | false | To manually set read-only to the checkbox. |
Name | Value | Default |
---|---|---|
size | lg | md | sm | md |
function App() {const [values, setValues] = useState(["Eng"])return (<CheckboxGroupvalue={values}onChange={(keys) => {setValues(keys)}}><VStack space="3xl"><Checkbox value="Eng"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Framer</CheckboxLabel></Checkbox><Checkbox value="invison"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Invision Studio</CheckboxLabel></Checkbox><Checkbox value="adobe"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Adobe XD</CheckboxLabel></Checkbox></VStack></CheckboxGroup>)}
function App() {const [values, setValues] = useState(["Illustration"])return (<CheckboxGroupvalue={values}onChange={(keys) => {setValues(keys)}}><HStack space="2xl"><Checkbox value="Illustration"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Illustration</CheckboxLabel></Checkbox><Checkbox value="Animation"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Animation</CheckboxLabel></Checkbox><Checkbox value="Typography"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Typography</CheckboxLabel></Checkbox></HStack></CheckboxGroup>)}
function App() {const [values, setValues] = useState(["Design"])return (<CheckboxGroupvalue={values}onChange={(keys) => {setValues(keys)}}><VStack space="2xl"><Box><Checkbox value="Design"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Design</CheckboxLabel></Checkbox><Text size="sm" ml="$7">Subscribe to updates from the Design Feed</Text></Box><Box><Checkbox value="Marketing"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Marketing</CheckboxLabel></Checkbox><Text size="sm" ml="$7">Subscribe to updates from the Marketing Feed</Text></Box></VStack></CheckboxGroup>)}
<FormControl><VStack space="sm"><Heading size="sm">Sign up for newsletters</Heading><Checkbox><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Daily Bits</CheckboxLabel></Checkbox><Checkbox><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Event Updates</CheckboxLabel></Checkbox><Checkbox><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Sponsorship</CheckboxLabel></Checkbox><Text size="sm">Subscribe to newsletters for updates</Text></VStack></FormControl>
function App() {const [values, setValues] = useState(["Jane"])return (<CheckboxGroupvalue={values}onChange={(keys) => {setValues(keys)}}><VStack space="lg" w="$40"><Checkbox justifyContent="space-between" value="Jane"><CheckboxLabel>Jane Cooper</CheckboxLabel><CheckboxIndicator><CheckboxIcon as={CheckIcon} /></CheckboxIndicator></Checkbox><Checkbox value="Wade" justifyContent="space-between"><CheckboxLabel>Wade Warren</CheckboxLabel><CheckboxIndicator><CheckboxIcon as={CheckIcon} /></CheckboxIndicator></Checkbox><Checkbox justifyContent="space-between" value="Robert"><CheckboxLabel>Robert Fox</CheckboxLabel><CheckboxIndicator><CheckboxIcon as={CheckIcon} /></CheckboxIndicator></Checkbox></VStack></CheckboxGroup>)}
function App() {const [values, setValues] = React.useState(["UX Research"])return (<CheckboxGroupvalue={values}onChange={(keys) => {setValues(keys)}}><VStack space="md"><Checkbox value="UX Research"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>UX Research</CheckboxLabel></Checkbox><Checkbox value="Software"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Software Development</CheckboxLabel></Checkbox></VStack></CheckboxGroup>)}
function App() {const radioRef = useRef(null)const handleCheckboxChange = (e) => {e.preventDefault()const checkboxValue = radioRef.current.checked}return (<CheckboxGroup ref={radioRef}><VStack space="md"><Checkbox onChange={handleCheckboxChange} value="Apartments"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Apartments</CheckboxLabel></Checkbox><Checkbox onChange={handleCheckboxChange} value="Residents"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Residents</CheckboxLabel></Checkbox></VStack></CheckboxGroup>)}
function CheckboxExample() {const [values, setValues] = React.useState([])return (<Center><CheckboxGroup value={values} onChange={setValues}><VStack space="sm"><Checkbox isDisabled={true} value="Label 1"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Label 1</CheckboxLabel></Checkbox><Checkbox value="Label 2"><CheckboxIndicator mr="$2"><CheckboxIcon as={CheckIcon} /></CheckboxIndicator><CheckboxLabel>Label 2</CheckboxLabel></Checkbox></VStack></CheckboxGroup></Center>)}