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

Function BadgeExample

example/src/Examples/BadgeExample.tsx:17–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15import ScreenWrapper from '../ScreenWrapper';
16
17const BadgeExample = () => {
18 const [visible, setVisible] = React.useState<boolean>(true);
19 const { isV3 } = useExampleTheme();
20
21 return (
22 <ScreenWrapper>
23 <View style={[styles.row, styles.item]}>
24 <Text style={styles.label} variant="bodyMedium">
25 Show badges
26 </Text>
27 <Switch
28 value={visible}
29 onValueChange={(visible) => setVisible(visible)}
30 />
31 </View>
32 <List.Section title="Text">
33 <View style={styles.row}>
34 <View style={styles.item}>
35 <IconButton icon="palette-swatch" size={36} style={styles.button} />
36 <Badge visible={visible} style={styles.badge}>
37 12
38 </Badge>
39 </View>
40 <View style={styles.item}>
41 <IconButton icon="inbox" size={36} style={styles.button} />
42 <Badge
43 visible={visible}
44 style={[
45 styles.badge,
46 {
47 backgroundColor: isV3
48 ? MD3Colors.primary80
49 : MD2Colors.blue500,
50 },
51 ]}
52 >
53 999+
54 </Badge>
55 </View>
56 </View>
57 </List.Section>
58 <List.Section title="Dot">
59 <View style={styles.row}>
60 <View style={styles.item}>
61 <IconButton icon="book-open" size={36} style={styles.button} />
62 <Badge visible={visible} style={styles.badge} size={isV3 ? 6 : 8} />
63 </View>
64 <View style={styles.item}>
65 <IconButton icon="receipt" size={36} style={styles.button} />
66 <Badge visible={visible} style={styles.badge} size={isV3 ? 6 : 8} />
67 </View>
68 </View>
69 </List.Section>
70 </ScreenWrapper>
71 );
72};
73
74BadgeExample.title = 'Badge';

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…