Multi-Select Screen with Checkboxes
Screen is created using these React Native Core Components: <SafeAreaView />, <View />, <TouchableOpacity />, <Text />, <ScrollView />
import React, { useState } from 'react';
import {
StyleSheet,
SafeAreaView,
View,
TouchableOpacity,
Text,
ScrollView,
} from 'react-native';
import FeatherIcon from 'react-native-vector-icons/Feather''@expo/vector-icons/Feather';
const skillCategories = [
{
id: 'languages',
name: 'Languages',
icon: 'language',
skills: [
{ emoji: '🇪🇸', name: 'Spanish' },
{ emoji: '🇫🇷', name: 'French' },
{ emoji: '🇯🇵', name: 'Japanese' },
{ emoji: '🇨🇳', name: 'Mandarin' },
{ emoji: '🇩🇪', name: 'German' },
{ emoji: '🇮🇹', name: 'Italian' },
{ emoji: '🇰🇷', name: 'Korean' },
{ emoji: '🇵🇹', name: 'Portuguese' },
],
},
{
id: 'art',
name: 'Art & Design',
icon: 'brush',
skills: [
{ emoji: '✏️', name: 'Drawing' },
{ emoji: '🎨', name: 'Painting' },
{ emoji: '💻', name: 'Digital Art' },
{ emoji: '📸', name: 'Photography' },
{ emoji: '🎬', name: 'Animation' },
{ emoji: '🖌️', name: 'Illustration' },
{ emoji: '🗿', name: 'Sculpture' },
{ emoji: '📝', name: 'Typography' },
{ emoji: '🌈', name: 'Color Theory' },
{ emoji: '🏠', name: 'Interior Design' },
{ emoji: '👗', name: 'Fashion Design' },
],
},
];
export default function Example() {
const [form, setForm] = useState({
selectedSkills: [],
searchQuery: '',
});
return (
<SafeAreaView style={{ flex: 1, backgroundColor: '#F4EFF3' }}>
<View style={styles.header}>
<TouchableOpacity
onPress={() => {
// handle onPress
}}
style={styles.headerAction}>
<FeatherIcon
color="#F82E08"
name="arrow-left"
size={24} />
</TouchableOpacity>
<Text style={styles.title}>What Do You Teach?</Text>
<Text style={styles.subtitle}>
Discover and master new skills with expert-led video courses
</Text>
</View>
<ScrollView>
{skillCategories.map((category, categoryIndex) => (
<View key={category.id} style={styles.section}>
<Text style={styles.sectionTitle}>{category.name}</Text>
<View style={styles.skillsGrid}>
{category.skills.map((skill, skillIndex) => {
const isSelected = form.selectedSkills.includes(skill.name);
return (
<TouchableOpacity
key={`${categoryIndex}-${skillIndex}`}
onPress={() => {
const newSkills = isSelected
? form.selectedSkills.filter(s => s !== skill.name)
: [...form.selectedSkills, skill.name];
setForm({ ...form, selectedSkills: newSkills });
}}
style={[
styles.skillCard,
isSelected
? { borderColor: '#F82E08', backgroundColor: '#FFF5F5' }
: {},
]}>
<View>
<Text style={styles.skillEmoji}>{skill.emoji}</Text>
<Text style={styles.skillName}>{skill.name}</Text>
</View>
{isSelected && (
<FeatherIcon
color="#F82E08"
name="check-circle"
size={20} />
)}
</TouchableOpacity>
);
})}
</View>
</View>
))}
</ScrollView>
<View style={styles.formFooter}>
<TouchableOpacity
onPress={() => {
// handle onPress
}}>
<View style={styles.btn}>
<Text style={styles.btnText}>Continue</Text>
</View>
</TouchableOpacity>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
title: {
fontSize: 34,
fontWeight: 'bold',
color: '#181818',
marginBottom: 12,
},
subtitle: {
fontSize: 15,
lineHeight: 20,
fontWeight: '500',
color: '#889797',
},
skillsGrid: {
flexDirection: 'row',
flexWrap: 'wrap',
margin: -6,
},
formFooter: {
marginTop: 'auto',
marginBottom: 24,
paddingTop: 12,
paddingHorizontal: 24,
paddingBottom: 0,
fontSize: 15,
lineHeight: 20,
fontWeight: '400',
color: '#9fa5af',
textAlign: 'center',
},
/** Header */
header: {
paddingHorizontal: 24,
marginBottom: 28,
},
headerAction: {
width: 40,
height: 40,
borderRadius: 9999,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ffdada',
marginBottom: 16,
},
/** Section */
section: {
marginBottom: 16,
paddingVertical: 0,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 13,
fontWeight: '600',
color: '#889797',
marginBottom: 12,
textTransform: 'uppercase',
},
skillCard: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'flex-start',
width: '30%',
margin: 4,
padding: 8,
backgroundColor: '#fff',
borderRadius: 8,
borderWidth: 1.5,
borderColor: '#e5e7eb',
},
skillEmoji: {
fontSize: 16,
lineHeight: 20,
marginBottom: 2,
},
skillName: {
fontSize: 13,
lineHeight: 18,
fontWeight: '500',
color: '#1d2a32',
marginTop: 4,
},
/** Button */
btn: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 8,
paddingVertical: 16,
paddingHorizontal: 24,
borderWidth: 1,
backgroundColor: '#F82E08',
borderColor: '#F82E08',
},
btnText: {
fontSize: 17,
lineHeight: 22,
fontWeight: 'bold',
color: '#fff',
},
});Dependencies
Before getting started, make sure you have all the necessary dependencies for this component. Follow the steps below to install any missing dependencies.
-
Install the package.
npm install --save react-native-vector-icons
-
Link the native packages for iOS.
npx pod-install
In React Native 0.60+ the CLI autolink feature links the module while building the app.
-
Add Fonts to the
Info.plistfile.
Open your XCode project, right click on the Info.plist, and select Open As -> Source Code.
Next, copy the fonts below into your Info.plist.
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>FontAwesome6_Brands.ttf</string>
<string>FontAwesome6_Regular.ttf</string>
<string>FontAwesome6_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
<string>Fontisto.ttf</string>
</array>
Note: You can only select the fonts you would like to use in your React Native Application.
After you added these fonts the Info.plist file should look like this:
![]()
-
Add
fonts.gradlefor Android.
Open android/app/build.gradle (NOT android/build.gradle) and add the following code to the bottom:
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
If you want to customize fonts, use:
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'EvilIcons.ttf' ]
]
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
Original instructions can be found on Github: https://github.com/oblador/react-native-vector-icons