DEV Community

Ajmal Hasan
Ajmal Hasan

Posted on

2 1

Using react-native-vector-icons in React Native

react-native-vector-icons is a library that lets you integrate a variety of icons into your React Native app, improving design and user experience. It supports popular icon sets like FontAwesome, Material Icons, and Ionicons. Explore available icons here.


Step 1: Install the Library

Install via npm or Yarn:

npm install react-native-vector-icons
Enter fullscreen mode Exit fullscreen mode

or

yarn add react-native-vector-icons
Enter fullscreen mode Exit fullscreen mode

Available Icon Sets

Icon libraries available include:

  • AntDesign (298 icons)
  • Entypo (411 icons)
  • EvilIcons (70 icons)
  • Feather (286 icons)
  • FontAwesome 5 (1,598 free icons)
  • Ionicons (1,338 icons)
  • MaterialIcons (2,189 icons)
  • MaterialCommunityIcons (6,596 icons)

Explore other sets here.


Step 2: Configure Fonts

Android Setup

In android/app/build.gradle, add the fonts:

react {
  project.ext.vectoricons = [
      iconFontNames: ['MaterialCommunityIcons.ttf', 'FontAwesome.ttf', 'AntDesign.ttf']
  ]
  apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
}
Enter fullscreen mode Exit fullscreen mode

iOS Setup

In Info.plist, add the fonts:

<key>UIAppFonts</key>
<array>
    <string>MaterialCommunityIcons.ttf</string>
    <string>FontAwesome.ttf</string>
    <string>AntDesign.ttf</string>
</array>
Enter fullscreen mode Exit fullscreen mode

Also, in react-native.config.js, disable iOS auto-linking:

module.exports = {
  'react-native-vector-icons': {
    platforms: {
      ios: null,
    },
  },
};
Enter fullscreen mode Exit fullscreen mode

Run the command:

npx react-native-asset
Enter fullscreen mode Exit fullscreen mode

Step 3: Use Icons in Your Components

Import and use icons like this:

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

const MyComponent = () => (
  <Icon name="home" size={30} color="#900" />
);
Enter fullscreen mode Exit fullscreen mode

You can replace MaterialCommunityIcons with other icon sets as needed.


Conclusion

By integrating react-native-vector-icons, you can enhance your app with a wide range of high-quality icons. The setup process is simple and involves configuring a few files for Android and iOS.

JavaScript tools that help you ship faster

JavaScript tools that help you ship faster

Skip boilerplate and focus on features. Kinde handles auth, access control, and billing behind the scenes.

Get a free account

Top comments (0)

Heroku

Tired of jumping between terminals, dashboards, and code?

Check out this demo showcasing how tools like Cursor can connect to Heroku through the MCP, letting you trigger actions like deployments, scaling, or provisioning—all without leaving your editor.

Learn More

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay