```ts import { HeroOutline } from '@nandorojo/heroicons'
npm install @nandorojo/heroicons``ts
import { HeroOutline } from '@nandorojo/heroicons'
export const Icon = () =>
`
- 😎 Free, beautiful icons
- 🔥 Customizable with react-native-svg props
- 🌲 Tree-shaken components
- 🤖 TypeScript support
- 📈 JS-only (+ works with Expo)
Heroicons is an awesome icon set made by the creators of Tailwind CSS
. This library exports React Native components for each of its free icons, since their repo only supports React and Vue.
See the example snack 🍔.
This is a fork of my similar iconic icon set for React Native: https://github.com/nandorojo/react-native-iconic
`sh`
yarn add @nandorojo/heroicons react-native-svg
There are 2 ways to import the icons:
1. Single import
`tsx
import { HeroOutline, HeroSolid, HeroSolid20 } from '@nandorojo/heroicons'
export const Icon = () =>
`
2. Tree-shaken import
Alternatively, you could import the icons individually.
While method 1 _should_ tree shake since it's configured to use ESM with tree shaking optimizations, this import method is a safer bet if you're concerned about tree shaking.
`tsx
import { AcademicCap } from '@nandorojo/heroicons/24/outline'
export const Icon = () =>
`
The import paths are 20/solid, 24/solid, & 24/outline.
You can also import * as HeroOutline:
`tsx
import * as HeroOutline from '@nandorojo/heroicons/24/outline'
export const Icon = () =>
`
For a full directory of components, see the Hero Icons website.
`tsx`
`tsx`
Each icon component accepts all the props from react-native-svg's Svg component. Reference their docs.
This library uses react-native-svg. The components are generated by svgr. I downloaded all the free icons from heroicons and ran a script to codegen the files from there.
Since Heroicons updates their icons somewhat frequently, you may want to import the new ones. These are the steps to update this library with new icons:
1. Fork this repo
2. Download the full folder of free icons from heroicons.com's GitHub repository
3. Replace the generate/hero/optimized folder with the the optimized folder from their repositoryyarn install
4. Run and yarn prepare`
5. Commit your changes, and open a PR!
There weren't any answers on this discussion so I decided to make it myself.
PS after building this, I found this similar library too.