You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4261ed6
Browse filesBrowse the repository at this point in the historyBrowse files
[React Native Nano Icons](https://nano-icons.swmansion.com/) provides a way to use custom SVG files as performant font-based icons, both in JavaScript-based and native navigation components.
549
+
[React Native Nano Icons](https://nano-icons.swmansion.com/) provides a way to use custom SVG files as performant font-based icons.
550
550
551
-
To use it, install the `react-native-nano-icons` package, then set it up depending on where the icons are rendered.
551
+
To use it, install the `react-native-nano-icons` package, then follow the [quick start](https://github.com/software-mansion-labs/react-native-nano-icons#-quick-start) to set it up with your SVG icons.
552
552
553
-
For JavaScript-based components, such as the `custom`[implementation](bottom-tab-navigator.md#implementation) of Bottom Tab Navigator, follow the [quick start](https://github.com/software-mansion-labs/react-native-nano-icons#-quick-start) and use the `Icon` component created with `createNanoIconSet`.
554
-
555
-
For native components, such as the tab bar with the `native` implementation, follow the [native symbols setup](https://github.com/software-mansion-labs/react-native-nano-icons#-native-symbols) to generate SF Symbols on iOS and vector drawables on Android from your SVG files, and rebuild the app.
556
-
557
-
Pass the SVG file name to the `nativeNanoSymbol` function to create a type-safe icon. For example, for `newspaper.svg`:
553
+
Then you can use the icon by passing the name to the `nativeNanoSymbol` function:
@@ -564,6 +560,8 @@ import { nativeNanoSymbol } from 'react-native-nano-icons/symbols';
564
560
tabBarIcon:nativeNanoSymbol('newspaper'),
565
561
```
566
562
563
+
Here, we use `newspaper` as the icon name, which is the filename `newspaper.svg` without extension.
564
+
567
565
It returns `{ type: 'sfSymbol', name: 'nano.newspaper' }` on iOS, and `{ type: 'image', source: { uri: 'nano_newspaper' } }` on Android, which resolves to a native vector drawable asset.
568
566
569
567
The second argument specifies how to color the symbol:
@@ -608,6 +606,8 @@ function MyComponent() {
608
606
}
609
607
```
610
608
609
+
For more general usage, the library also provides a font-based `Icon` component, created with [`createNanoIconSet`](https://github.com/software-mansion-labs/react-native-nano-icons#createnanoiconset), to render the icons in your own components.
The React Native Vector Icons library provides various sets of font icons. Font icons cannot be used directly in most native navigation components such as tab bars or headers. But they can be [rasterized into images](https://github.com/oblador/react-native-vector-icons?tab=readme-ov-file#usage-as-png-imagesource-object) and used with the `type: 'image'` option.
0 commit comments