Skip to main content

Basic Usage

To use a icon font, you have to make sure you import them into your project. Only after the font is loaded, you can use Icon set.

'icon': require('../assets/fonts/font-icon.ttf')

Read more on about pre-loading and caching assets.

You can use your own set of icons. See section Custom Icons how to create and use your set of icons.

CAUTION

FlexNative Icons uses expo-font from Expo wich require expo dependencies. If you are using plain react-native without expo you need to install react-native-unimodules.

Fallow this link to Migrating to Expo modules.

/src/app.jsx
import React from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View } from 'react-native';

import useCachedResources from './hooks/useCachedResources';
import Icon, { Spinner } from '@flexnative/icons';

export default function App() {
const isLoadingComplete = useCachedResources();

if (!isLoadingComplete) {
return null;
} else {
return (
<View style={styles.container}>
<StatusBar style="auto" />
<Icon name='sun' color='rgb(255, 174, 16)' size={32} />
<Spinner name='spinner' style={styles.spinner} />
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
spinner: {
fontSize: 32,
color: '#EF0003'
},
box: {
width: 50,
height: 50,
}
});

Properties

IconProps

Interface representing the properties for an icon component.

info

Icon and Spinner components expects props of type IconProp which extends TextProps from React Native

NameTypeRequiredDefault ValueDescription
nameIconNametrueundefinedName of the icon to use (Specific to the chosen Icon Pack)
sizeFontSizefalsetheme.fontSize.defaultIcon size.
colorBaseColors | ColorValuefalsetheme.colors.textIcon color one of color used by BaseTheme<TColors> or given ColorValue by user.

IconName

Interface representing the names of various icons. Each property is a readonly string representing a specific icon name. These names can be used to access the corresponding Unicode value from the icons object.

NameUnicode ValueIcon
rocketrocket
locklock
unlockunlock
filet-jsxfilet-jsx
filet-tsxfilet-tsx
file-codefile-code
folder-openfolder-open
shield-lockshield-lock
fingerprintfingerprint
layoutlayout
sort-number-descsort-number-desc
sort-number-ascsort-number-asc
sort-alphabet-descsort-alphabet-desc
sort-alphabet-ascsort-alphabet-asc
unsortunsort
puzzlepuzzle
multi-devicemulti-device
lightninglightning
gridiconsgridicons
light-darklight-dark
color-paletecolor-palete
checkcheck
badgebadge
menumenu
bookmarkbookmark
labellabel
gridgrid
text-blocktext-block
popuppopup
modalmodal
filet-jsonfilet-json
file-excelfile-excel
avataravatar
usersusers
chevron-leftchevron-left
caret-downcaret-down
caret-upcaret-up
sunsun
moonmoon
starstar
imageimage
check-listcheck-list
checkboxcheckbox
number-inputnumber-input
buttonbutton
text-boxtext-box
webweb
androidandroid
appleapple
close-circleclose-circle
material-designmaterial-design
spinner-1spinner-1
spinner-2spinner-2
spinner-3spinner-3
sort-altsort-alt
spinnerspinner
spinner-iosspinner-ios
file-pdffile-pdf
paint-brushpaint-brush
trashtrash

Using Icon component

Example ouf usecase with Icon component.

import Icon from '@flexnative/icons';

<Icon name='sun' color='rgb(255, 174, 16)' size={32} />

Using with Plain text

You can use icons through Icon Component from @flexnative/icons or as a usual text with Text component from react-native as the following examples:

import { StyleSheet, Text } from 'react-native';

<Text style={styles.text}>{'\u0053'}</Text>

const styles = StyleSheet.create({
text: {
fontFamily: 'icon',
color: 'rgb(255, 174, 16)',
fontSize: 32
}
});

Spinner

import { Spinner } from '@flexnative/icons';

<Spinner name='sun' color='rgb(255, 174, 16)' size={32} />