Convert Figma logo to code with AI

corymsmith logoreact-native-icons

Quick and easy icons in React Native

1,143
141
1,143
1

Top Related Projects

Customizable Icons for React Native with support for image source and full styling.

SVG library for React Native, React Native Web, and plain React web projects.

4,466

Universal icon framework. One syntax for FontAwesome, Material Design Icons, DashIcons, Feather Icons, EmojiOne, Noto Emoji and many other open source icon sets (over 150 icon sets and 200k icons). SVG framework, React, Vue and Svelte components!

Quick Overview

React Native Icons is a library that provides a comprehensive set of customizable icons for React Native applications. It offers a wide variety of icon sets and allows developers to easily integrate and style icons in their mobile apps.

Pros

  • Large selection of icon sets available
  • Easy integration with React Native projects
  • Customizable icon properties (size, color, etc.)
  • Regular updates and community support

Cons

  • May increase app bundle size if many icons are used
  • Some icon sets might require additional licensing
  • Learning curve for customizing complex icon styles
  • Potential performance impact if overused in the app

Code Examples

  1. Basic icon usage:
import Icon from 'react-native-icons';

const MyComponent = () => (
  <Icon name="rocket" size={30} color="#900" />
);
  1. Using a specific icon set:
import Icon from 'react-native-icons';

const MyComponent = () => (
  <Icon name="logo-github" type="ionicon" size={25} color="#333" />
);
  1. Creating a custom icon button:
import React from 'react';
import { TouchableOpacity } from 'react-native';
import Icon from 'react-native-icons';

const IconButton = ({ onPress, name, color }) => (
  <TouchableOpacity onPress={onPress}>
    <Icon name={name} size={24} color={color} />
  </TouchableOpacity>
);

Getting Started

  1. Install the package:
npm install react-native-icons
  1. Link the native modules (for React Native < 0.60):
react-native link react-native-icons
  1. Import and use in your React Native component:
import Icon from 'react-native-icons';

const MyComponent = () => (
  <Icon name="heart" size={20} color="red" />
);

Note: For React Native 0.60 and above, the linking process is automatic. Make sure to run pod install in the iOS directory if you're developing for iOS.

Competitor Comparisons

Customizable Icons for React Native with support for image source and full styling.

Pros of react-native-vector-icons

  • Larger icon set with support for multiple icon libraries
  • More actively maintained with frequent updates
  • Better documentation and community support

Cons of react-native-vector-icons

  • Slightly larger package size due to extensive icon sets
  • May require additional setup for custom icons

Code Comparison

react-native-icons:

import Icon from 'react-native-icons';

<Icon
  name='ion|beer'
  size={30}
  color='#000'
  style={styles.icon}
/>

react-native-vector-icons:

import Icon from 'react-native-vector-icons/Ionicons';

<Icon
  name='beer'
  size={30}
  color='#000'
  style={styles.icon}
/>

The main difference in usage is that react-native-vector-icons requires importing specific icon sets, while react-native-icons uses a prefix in the name prop to specify the icon set. react-native-vector-icons offers a more modular approach, allowing developers to import only the icon sets they need, potentially reducing bundle size.

Overall, react-native-vector-icons is generally considered the more robust and widely-used option, with better maintenance and a larger selection of icons. However, react-native-icons may be simpler to use for basic icon needs.

SVG library for React Native, React Native Web, and plain React web projects.

Pros of react-native-svg

  • More actively maintained with frequent updates
  • Supports a wider range of SVG features and elements
  • Better performance for complex SVG rendering

Cons of react-native-svg

  • Slightly larger package size
  • May require more setup and configuration for basic use cases

Code Comparison

react-native-svg:

import Svg, { Circle, Rect } from 'react-native-svg';

<Svg height="100" width="100">
  <Rect x="0" y="0" width="100" height="100" fill="black" />
  <Circle cx="50" cy="50" r="30" fill="yellow" />
</Svg>

react-native-icons:

import Icon from 'react-native-icons';

<Icon
  name='ion|beer'
  size={30}
  color='#887700'
  style={styles.beer}
/>

react-native-svg offers more flexibility in creating custom SVG elements, while react-native-icons provides a simpler API for using pre-defined icons. react-native-svg is better suited for projects requiring complex SVG manipulation, whereas react-native-icons is more appropriate for quick implementation of common icon sets.

4,466

Universal icon framework. One syntax for FontAwesome, Material Design Icons, DashIcons, Feather Icons, EmojiOne, Noto Emoji and many other open source icon sets (over 150 icon sets and 200k icons). SVG framework, React, Vue and Svelte components!

Pros of Iconify

  • Supports a vast collection of over 100,000 icons from various icon sets
  • Framework-agnostic, can be used with React, Vue, Svelte, and more
  • Offers a unified API for all icon sets, simplifying icon management

Cons of Iconify

  • Requires additional setup and configuration compared to React Native Icons
  • May have a larger bundle size due to its extensive icon library
  • Learning curve might be steeper for developers new to the Iconify ecosystem

Code Comparison

React Native Icons:

import Icon from 'react-native-icons';

<Icon
  name='ion|beer'
  size={30}
  color='#000'
  style={styles.icon}
/>

Iconify:

import { Icon } from '@iconify/react';

<Icon
  icon="ion:beer"
  width={30}
  height={30}
  color="#000"
/>

Both libraries offer similar syntax for icon usage, but Iconify provides a more consistent API across different icon sets. React Native Icons is specifically tailored for React Native, while Iconify offers broader framework support. Iconify's extensive icon collection and unified API make it more versatile, but React Native Icons may be simpler to integrate for React Native-specific projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

WARNING: This library is discontinued, I highly recommend using https://github.com/oblador/react-native-vector-icons

There's far bigger problems to solve in the open source and React Native communities than competing icon libraries so I'll be focusing on pushing forward other initiatives.

React Native Icons

npm version

Includes 5 different icon fonts and 2,444 icons.

Installation

npm install react-native-icons@latest --save

If you need to support React Native version < 0.12.0-rc use:

npm install react-native-icons@0.4.0 --save

Note that 0.4.0 does not support Android.

Getting started - iOS

  1. In XCode, in the project navigator right click Libraries ➜ Add Files to [your project's name]
  2. Go to node_modules ➜ react-native-icons➜ ios and add ReactNativeIcons.xcodeproj
  3. Add libReactNativeIcons.a (from 'Products' under ReactNativeIcons.xcodeproj) to your project's Build Phases ➜ Link Binary With Libraries phase
  4. Add the font files you want to use into the Copy Bundle Resources build phase of your project (click the '+' and click 'Add Other...' then choose the font files from node_modules/react-native-icons/ios/ReactNativeIcons/Libraries/FontAwesomeKit).
  5. Run your project (Cmd+R)

Getting started - Android

  • In android/setting.gradle
...
include ':react-native-icons'
project(':react-native-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-icons/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':react-native-icons')
}
  • register module (in MainActivity.java)
import com.smixx.reactnativeicons.ReactNativeIcons;  // <--- import
import java.util.Arrays; // <--- import this if you want to specify which fonts to load
import com.smixx.reactnativeicons.IconFont; // <--- import this if you want to specify which fonts to load

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new ReactNativeIcons())              // <------ add here
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "example", null);

    setContentView(mReactRootView);
  }

  ......

}
  • Copy the font files and .json files for the fonts you want to use into android/app/src/main/assets from node_modules/react-native-icons/fonts

Not supported on Android yet:

  • Tab Bar
  • Stacked Icons

Custom fonts

iOS

Custom fonts are not yet supported for iOS

Android

1. Copy the font file to your apps assets directory

2. Create a myfontname.json mapping file for the font, this is used to look up the mapping file and is used

Create json file (newiconfont.json) that contains a map of css names to HTML encoded unicode characters., examples in /fonts directory

{
  "alert": "&#xf101",
  "alert-circled": "&#xf100",
  "android-add": "&#xf2c7",
  "android-add-circle": "&#xf359",
...
}

3. Include fonts

  1. Copy font file and .json file to your apps assets directory 3.) In MainActivity.java, add the icon font, first parameter is the prefix you want to use (ex. typicons|globe), second is the filename of the font.
 mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .addPackage(new ReactNativeIcons(Arrays.asList(
                        new IconFont("typicons", "typicons.ttf")
                )))
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();

Notes

  • You only need to include the icon font files you want to use
  • Icon style must set a width and height, or the icon will not be visible
  • You may need to restart your node server for the icon font files to be included.
  • An icon has a name, size, and a color (optional)
  • Color can be provide via the color property or via a style

Example of icons

var { Icon, } = require('react-native-icons');


<Icon
  name='ion|beer'
  size={150}
  color='#887700'
  style={styles.beer}
/>
<Icon
  name='zocial|github'
  size={70}
  color='black'
  style={styles.github}
/>
<Icon
  name='fontawesome|facebook-square'
  size={70}
  color='#3b5998'
  style={styles.facebook}
/>
<Icon
  name='foundation|lightbulb'
  size={30}
  color='#777777'
  style={styles.lightbulb}
/>

<Icon
  name='material|face'
  size={30}
  color='#333333'
  style={styles.face}
/>

Stacked icons

<Icon
  name='fontawesome|square'
  size={80}
  color='#55acee'
  style={styles.twitterOutline}>
  <Icon
    name='fontawesome|twitter'
    size={50}
    color='#ffffff'
    style={styles.twitterIcon}/>
</Icon>

With the following styles to center them:

var styles = StyleSheet.create({
  twitterOutline: {
    flexDirection: 'column',
    width: 70,
    height: 70,
    alignItems: 'center'
  },
  twitterIcon: {
    flex: 1,
    width: 40,
    height: 40
  },
});

Custom tab bar


var { TabBarIOS, } = require('react-native-icons');
var TabBarItemIOS = TabBarIOS.Item;

var Example = React.createClass({
  getInitialState: function() {
    return {
      selectedTab: 'home',
      notifCount: 0,
      presses: 0,
    };
  },
  render: function () {
    return (
      <TabBarIOS
        selectedTab={this.state.selectedTab}
        tintColor={'#c1d82f'}
        barTintColor={'#000000'}
        styles={styles.tabBar}>
        <TabBarItemIOS
          name="home"
          iconName={'ion|ios-home-outline'}
          selectedIconName={'ion|ios-home'}
          title={''}
          iconSize={32}
          accessibilityLabel="Home Tab"
          selected={this.state.selectedTab === 'home'}
          onPress={() => {
            this.setState({
              selectedTab: 'home',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
        <TabBarItemIOS
            name="articles"
            iconName={'ion|ios-paper-outline'}
            selectedIconName={'ion|ios-paper'}
            title={''}
            iconSize={32}
            accessibilityLabel="Articles Tab"
            selected={this.state.selectedTab === 'articles'}
            onPress={() => {
            this.setState({
              selectedTab: 'articles',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
        <TabBarItemIOS
            name="messages"
            iconName={'ion|chatboxes'}
            title={''}
            iconSize={32}
            accessibilityLabel="Messages Tab"
            selected={this.state.selectedTab === 'messages'}
            onPress={() => {
            this.setState({
              selectedTab: 'messages',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
        <TabBarItemIOS
            name="settings"
            iconName={'ion|ios-gear-outline'}
            selectedIconName={'ion|ios-gear'}
            title={''}
            iconSize={32}
            accessibilityLabel="Settings Tab"
            selected={this.state.selectedTab === 'settings'}
            onPress={() => {
            this.setState({
              selectedTab: 'settings',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
      </TabBarIOS>
    );
  }
});

Note: selectedIconName is optional. It defaults to iconName if not set. Also, there's another optional property named selectedIconSize, if you need to change the icon size when the tab is selected.

Included icon fonts

Screenshot

NPM DownloadsLast 30 Days