Skip to content

Instantly share code, notes, and snippets.

@ajsmth
Created July 6, 2021 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajsmth/55d9f16e6ef3e38707c16ee7d46413c6 to your computer and use it in GitHub Desktop.
Save ajsmth/55d9f16e6ef3e38707c16ee7d46413c6 to your computer and use it in GitHub Desktop.
Checkbox Sandbox
import Checkbox from 'expo-checkbox';
import React, { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default function App() {
const [isChecked, setChecked] = useState(false);
return (
<View style={styles.container}>
<View style={styles.section}>
<Checkbox style={styles.checkbox} value={isChecked} onValueChange={setChecked} />
<Text style={styles.paragraph}>Normal checkbox</Text>
</View>
<View style={styles.section}>
<Checkbox
style={styles.checkbox}
value={isChecked}
onValueChange={setChecked}
color={isChecked ? '#4630EB' : undefined}
/>
<Text style={styles.paragraph}>Custom colored checkbox</Text>
</View>
<View style={styles.section}>
<Checkbox style={styles.checkbox} disabled value={isChecked} onValueChange={setChecked} />
<Text style={styles.paragraph}>Disabled checkbox</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginHorizontal: 16,
marginVertical: 32,
},
section: {
flexDirection: 'row',
alignItems: 'center',
},
paragraph: {
fontSize: 15,
},
checkbox: {
margin: 8,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment