Managing custom icons in React Native can be challenging, especially with traditional tools like Fontello or Icomoon. These tools often lack dynamic integration with modern frameworks, making the process of adding or updating icons cumbersome and time-consuming.
Monicon offers a modern solution to these challenges, providing a flexible and efficient way to manage icons in your projects. Supporting popular frameworks like React, React Native, Next.js, Vue, Nuxt, Svelte, and more, Monicon simplifies the process of integrating custom icons. With access to over 200,000 icons from renowned libraries such as Material Design, Feather, and Font Awesome, Monicon ensures you have all the tools you need for a seamless and powerful icon management experience.
Why Use Monicon?
? Monicon Docs
? Monicon GitHub
Run the following command in your terminal to create a new Expo project:
npx create-expo-app my-new-app cd my-new-app
Run the following command to install necessary dependencies:
npm i -D @monicon/metro @monicon/babel-plugin @monicon/loader npx expo install @monicon/native react-native-svg
Create a metro.config.js file:
const { getDefaultConfig } = require("expo/metro-config"); const { withMonicon } = require("@monicon/metro"); const { loadLocalCollection } = require("@monicon/loader"); const config = getDefaultConfig(__dirname); module.exports = withMonicon(config, { customCollections: { "my-app": loadLocalCollection("assets/icons"), }, });
Create a babel.config.js file:
module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [["@monicon/babel-plugin"]], }; };
Add your custom icons to the assets/icons folder.
Example Icons
Modify the _layout.tsx file as follows:
npx create-expo-app my-new-app cd my-new-app
Run the following command to start your development server:
npm i -D @monicon/metro @monicon/babel-plugin @monicon/loader npx expo install @monicon/native react-native-svg
The above is the detailed content of How to add custom icons in React Native in 5. For more information, please follow other related articles on the PHP Chinese website!