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

info

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

NameTypeRequiredDefault ValueDescription
nameIconNametrueundefined
sizeIconSizefalse'normal'Icon size
colorIconColorfalsetheme.colors.textIcon color one of color used by BaseTheme<TColors> or given ColorValue by user.

IconName

NameUnicode ValueIcon
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
file-pdffile-pdf
paint-brushpaint-brush
trashtrash

IconSize

One of 'small' | 'normal' | 'medium' | 'large' | number

NameTypeValue
smallnumber16
normalnumber16
mediumnumber32
largenumber48
numberAny number value.

IconColor

One of 'default' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error' | 'dark' | 'light' | ColorValue

Name Type ValuePreview
LightDark
backgroundColorValuetheme.colors.background #f8f8f8 #000000
defaultColorValuetheme.colors.default #f5f5f5 #404040
cardColorValuetheme.colors.card #ffffff #232323
textColorValuetheme.colors.text #424242 #ffffff
borderColorValuetheme.colors.border #42424226 #ffffff1A
placeholderColorValuetheme.colors.placeholder #0000001A #FFFFFF1A
infoColorValuetheme.colors.info #3e80ed #3e80ed
successColorValuetheme.colors.success #5ec232 #5ec232
warningColorValuetheme.colors.warning #ffc107 #ffc107
errorColorValuetheme.colors.error #d51923 #d51923
darkColorValuetheme.colors.dark #424242 #424242
secondaryColorValuetheme.colors.secondary #666666 #5C5C5C
lightColorValuetheme.colors.light #ebebeb #ebebeb
primaryColorValuetheme.colors.primary #ff6358 #ff6358
ColorValueAny ColorValue chosen by developer.

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} />