GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.nativebase.io — CheckBox | NativeBase | Universal Components for React and React Native

CheckBox | NativeBase | Universal Components for React and React Native

NativeBase
3.4.x
🎉 Prompt to React Native UI
→
Search
⌘
K
Hire us
NativeBase
Introduction
Getting Started
Installation
Setup NativeBase Provider
Migration
Upgrading to v3
Upgrading to 3.2.0 from 3.x
Upgrading to 3.4.0 from 3.3.x
Components Migration
ActionSheet
Badge
Button
Card
Checkbox
DatePicker
DeckSwiper
Drawer
FABs
FooterTab
Form
Header
Icon
Layout
Picker
Radio Button
Searchbar
Segment
Spinner
SwipeList
Tabs
Thumbnail
Toast
Typography
Resources
Contribution
Creating a Universal App with NativeBase and Solito
Core Concepts
Utility First
Utility Props Specificity
Design Tokens
Pseudo Props: Overview
Pseudo Props: Dos & Don'ts
Internal Pseudo Props
Responsive
Features
Utility Props
Color mode (Dark Mode)
NativeBase Factory
SafeAreaView Props
Strict Mode
Accessibility
Theme
Default Theme
Customizing Theme
Customizing Fonts
Customizing Components
Making components dark mode compatible
Breakpoints
Using Theme
TypeScript
Layout
AspectRatio
Box
Center
Container
Flex
HStack / Row
Stack
VStack / Column
ZStack
Forms
Button
Pressable
Checkbox
FormControl
IconButton
Input
Link
Radio
Select
Slider
Switch
TextArea
Data Display
Badge
Divider
Feedback
Alert
Progress
Skeleton
Spinner
Toast
Typography
Text
Heading
Overlay
AlertDialog
Menu
Modal
Popover
Tooltip
Disclosure
ActionSheet
Media and Icons
Avatar
Icon
Image
Transition
PresenceTransition
Slide
Stagger
Others
Fab
Hidden
ReactNative Components
ScrollView
View
KeyboardAvoidingView
StatusBar
FlatList
SectionList
Hooks
useDisclose
useBreakpointValue
useClipboard
useMediaQuery
useTheme
useToken
useColorMode
useColorModeValue
useContrastText
useAccessibleColors
Examples
Todo-List
Kitchen Sink
Recipes
Designs
AppBar
Card
Drawer Navigation
Tab View
Swipe List
Forms
Form with Validation
Login/Signup Forms
SearchBar
Layout
App Drawer
Footer
More
Changelog
Testing
FAQ's
More Props
If you are starting a new project, please try gluestack-ui for better performance and new design.
CheckBox
The Checkbox component allows a user to select multiple values from various options in a form.
Show Code
Playground
const Example = () => {
return <HStack space={6}>
<Checkbox shadow={2} value="test" accessibilityLabel="This is a dummy checkbox" defaultIsChecked>
I accept the terms & conditions
</Checkbox>
</HStack>;
};
Examples
Basic
Playground
const Example = () => {
return <HStack space={6}>
<Checkbox value="test" accessibilityLabel="This is a dummy checkbox" />
<Checkbox value="test" accessibilityLabel="This is a dummy checkbox" defaultIsChecked />
</HStack>;
};
Controlled
Playground
const Example = () => {
const [groupValues, setGroupValues] = React.useState([]);
return <Checkbox.Group onChange={setGroupValues} value={groupValues} accessibilityLabel="choose numbers">
<Checkbox value="one" my={2}>
UX Research
</Checkbox>
<Checkbox value="two">Software Development</Checkbox>
</Checkbox.Group>;
};
Uncontrolled
Playground
const Example = () => {
return <Checkbox.Group accessibilityLabel="choose values">
<Checkbox value="one" my={2}>
UX Research
</Checkbox>
<Checkbox value="two">Software Development</Checkbox>
</Checkbox.Group>;
};
Disabled
Playground
const Example = () => {
return <VStack space={2}>
<Checkbox isDisabled value="one">
UX Research
</Checkbox>
<Checkbox isDisabled defaultIsChecked value="two">
Software Development
</Checkbox>
</VStack>;
};
Invalid
Playground
const Example = () => {
return <Checkbox isInvalid value="invalid">
Software Development
</Checkbox>;
};
Custom Color
Playground
const Example = () => {
return <Box alignItems="center">
<Stack direction={{
base: "column",
md: "row"
}} space={3} alignItems="flex-start">
<Checkbox value="danger" colorScheme="danger" defaultIsChecked>
Danger
</Checkbox>
<Checkbox value="info" colorScheme="info" defaultIsChecked>
Info
</Checkbox>
<Checkbox value="orange" colorScheme="orange" defaultIsChecked>
Orange
</Checkbox>
<Checkbox value="purple" colorScheme="purple" defaultIsChecked>
Purple
</Checkbox>
</Stack>
</Box>;
};
Custom Icon
Playground
const Example = () => {
return <Box alignItems="center">
<Stack direction={{
base: "column",
md: "row"
}} space={3} alignItems="flex-start">
<Checkbox value="orange" colorScheme="orange" size="md" icon={<Icon as={<MaterialCommunityIcons name="bullseye" />} />} defaultIsChecked>
Darts
</Checkbox>
<Checkbox value="dark" colorScheme="dark" size="md" icon={<Icon as={<MaterialCommunityIcons name="bat" />} />} defaultIsChecked>
Movie
</Checkbox>
<Checkbox colorScheme="red" value="red" size="md" icon={<Icon as={<MaterialCommunityIcons name="campfire" />} />} defaultIsChecked>
Camping
</Checkbox>
<Checkbox value="blue" colorScheme="blue" size="md" icon={<Icon as={<MaterialCommunityIcons name="chess-knight" />} />} defaultIsChecked>
Chess
</Checkbox>
</Stack>
</Box>;
};
Size
Playground
const Example = () => {
return <Center>
<VStack space={3}>
<Checkbox value="red" size="sm" defaultIsChecked>
UX Research
</Checkbox>
<Checkbox size="md" defaultIsChecked value="green">
UX Research
</Checkbox>
<Checkbox value="yellow" size="lg" defaultIsChecked>
UX Research
</Checkbox>
</VStack>
</Center>;
};
Checkbox Group
Playground
const Example = () => {
const [groupValue, setGroupValue] = React.useState(["Photography", "Gardening"]);
return <Box alignItems="center">
<VStack space={2}>
<HStack alignItems="baseline">
<Heading fontSize="lg">Hobbies</Heading>
</HStack>
<VStack>
<Box>
<Text>Selected: ({groupValue.length})</Text>
</Box>
</VStack>
<Checkbox.Group colorScheme="green" defaultValue={groupValue} accessibilityLabel="pick an item" onChange={values => {
setGroupValue(values || []);
}}>
<Checkbox value="Photography" my="1">
Photography
</Checkbox>
<Checkbox value="Writing" my="1">
Writing
</Checkbox>
<Checkbox value="Gardening" my="1">
Gardening
</Checkbox>
<Checkbox value="Cooking" my="1">
Cooking
</Checkbox>
</Checkbox.Group>
</VStack>
</Box>;
};
Form Controlled
Playground
const Example = () => {
const [groupValue, setGroupValue] = React.useState(["Phone", "Email"]);
return <Box alignItems="center">
<Container>
<FormControl isInvalid>
<FormControl.Label _text={{
fontSize: "lg",
bold: true
}}>
Preferred contact method
</FormControl.Label>
<Text fontSize="md">Selected Values: </Text>
<Checkbox.Group mt="2" colorScheme="green" defaultValue={groupValue} accessibilityLabel="choose multiple items" onChange={values => {
setGroupValue(values || []);
}} alignItems="flex-start">
<Checkbox value="Phone" my="1">
Phone
</Checkbox>
<Checkbox value="Email" my="1">
Email
</Checkbox>
<Checkbox value="Message" my="1">
Message
</Checkbox>
<Checkbox value="Fax" my="1">
Fax
</Checkbox>
</Checkbox.Group>
<FormControl.ErrorMessage _stack={{
alignItems: "flex-start"
}} leftIcon={<WarningOutlineIcon size="xs" mt={1} />}>
You must select at least three methods
</FormControl.ErrorMessage>
</FormControl>
</Container>
</Box>;
};
Basic (With Ref)
Playground
const Example = () => {
const myRef = React.useRef();
const [bg, setBg] = React.useState("#fa000050");
React.useEffect(() => {
const styleObj = {
backgroundColor: bg
};
if (Platform.OS !== "web") {
// @ts-ignore
myRef.current.setNativeProps({
style: styleObj
});
} else {
// @ts-ignore
myRef.current.setNativeProps({
style: styleObj
});
}
}, [myRef, bg]);
return <Box alignItems="flex-start">
<Checkbox value="success" colorScheme="success" icon={<Icon as={MaterialCommunityIcons} name="bullseye" opacity={1} />} wrapperRef={myRef} onChange={state => {
if (state) {
setBg("#00de0050");
} else {
setBg("#fa000050");
}
}}>
Archery
</Checkbox>
</Box>;
};
Props
Checkbox
Checkbox implements
FlexProps
,
ColorProps
,
LayoutProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
,
View
,
SafeAreaProps
,
PlatformProps
Checkbox.Group
CheckboxGroup implements
View
,
SafeAreaProps
,
PlatformProps
,
ColorProps
,
LayoutProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
,
FlexProps
id
assign id to checkbox group
Type: string
value
The value of the checkbox group.
Type: string[]
defaultValue
The initial value of the checkbox group.
Type: string[]
colorScheme
The color of the radio when it's checked. This should be one of the color keys in the theme (e.g."green", "red").
Type: ColorSchemeType
size
The size (width and height) of the checkbox.
Type: ResponsiveValue<"sm" | "md" | "lg">
onChange
The callback fired when any children Checkbox is checked or unchecked.
Type: (values: any) => any
_checkbox
Pass props will be passed to each checkbox.
Type: Partial<ICheckboxProps>
Styling
NativeBase ships with a default theme for each component. Check out the default theme of the checkbox
here
.
Info: We can easily extend the checkbox component theme using extendTheme function as described in the documentation
here
.
Accessibility
Uses React Native ARIA
@react-native-aria/checkbox
which follows the
Checkbox WAI-ARIA design pattern
.
Keyboard Interactions
Key
Description
Space
Checks/unchecks the checkbox.
Previous
Pressable
Next
FormControl
Quick Nav
Examples
Basic
Controlled
Uncontrolled
Disabled
Invalid
Custom Color
Custom Icon
Size
Checkbox Group
Form Controlled
Basic (With Ref)
Props
Checkbox
Checkbox.Group
Styling
Accessibility
Keyboard Interactions
MadeWithNativeBase
gluestack-ui
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.