MCPcopy Create free account
hub / github.com/callstack/react-native-paper / CheckboxExample

Function CheckboxExample

example/src/Examples/CheckboxExample.tsx:16–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14import ScreenWrapper from '../ScreenWrapper';
15
16const CheckboxExample = () => {
17 const [checkedNormal, setCheckedNormal] = React.useState<boolean>(true);
18 const [checkedCustom, setCheckedCustom] = React.useState<boolean>(true);
19 const [indeterminate, setIndeterminate] = React.useState<boolean>(true);
20
21 const { isV3 } = useExampleTheme();
22 const TextComponent = isV3 ? Text : Paragraph;
23
24 return (
25 <ScreenWrapper style={styles.container}>
26 <TouchableRipple onPress={() => setCheckedNormal(!checkedNormal)}>
27 <View style={styles.row}>
28 <TextComponent>Normal</TextComponent>
29 <View pointerEvents="none">
30 <Checkbox status={checkedNormal ? 'checked' : 'unchecked'} />
31 </View>
32 </View>
33 </TouchableRipple>
34
35 <TouchableRipple onPress={() => setCheckedCustom(!checkedCustom)}>
36 <View style={styles.row}>
37 <TextComponent>Custom</TextComponent>
38 <View pointerEvents="none">
39 <Checkbox
40 color={isV3 ? MD3Colors.error70 : MD2Colors.blue500}
41 status={checkedCustom ? 'checked' : 'unchecked'}
42 />
43 </View>
44 </View>
45 </TouchableRipple>
46
47 <TouchableRipple onPress={() => setIndeterminate(!indeterminate)}>
48 <View style={styles.row}>
49 <TextComponent>Indeterminate</TextComponent>
50 <View pointerEvents="none">
51 <Checkbox status={indeterminate ? 'indeterminate' : 'unchecked'} />
52 </View>
53 </View>
54 </TouchableRipple>
55
56 <View style={styles.row}>
57 <TextComponent>Checked (Disabled)</TextComponent>
58 <Checkbox status="checked" disabled />
59 </View>
60 <View style={styles.row}>
61 <TextComponent>Unchecked (Disabled)</TextComponent>
62 <Checkbox status="unchecked" disabled />
63 </View>
64 <View style={styles.row}>
65 <TextComponent>Indeterminate (Disabled)</TextComponent>
66 <Checkbox status="indeterminate" disabled />
67 </View>
68 </ScreenWrapper>
69 );
70};
71
72CheckboxExample.title = 'Checkbox';
73

Callers

nothing calls this directly

Calls 1

useExampleThemeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…