@ichava/js-icon-components/react-native is the React Native flavour: one forwardRef component per icon, drawn with react-native-svg.
| Import | Exports |
|---|---|
@ichava/js-icon-components/react-native/<pack> |
one component per icon, e.g. IconMug |
@ichava/js-icon-components/react-native |
Icon, createIcon, ELEMENTS, the NativeIconProps and NativeIchavaIcon types |
react-native-svg 15 or newer is an optional peer: install it in the app that uses this flavour.
import { IconMug } from '@ichava/js-icon-components/react-native/tabler';
import { IconKe } from '@ichava/js-icon-components/react-native/flag';
<IconMug size={20} color="#7c3aed" strokeWidth={1.5} />
<IconKe size={32} title="Kenya" />The ref is the Svg component. Any other Svg prop (style, onPress, testID) goes to the root.
- Elements are components. Each SVG element renders as its
react-native-svgcomponent (path→Path,linearGradient→LinearGradient);switchrenders as aG. Every element the SVG policy allows has one, whichtests/react-native.test.tschecks. - Attributes are props. Names take React's camel case,
xlink:hrefbecomeshref, and astylestring is split into props, becausereact-native-svgreads presentation from props. Web-only attributes (class,aria-*,data-*,xmlns) are dropped. - Accessibility uses React Native's props. Every icon has
accessibilityRole="image". Without atitleit is hidden (accessibilityElementsHidden,importantForAccessibility="no-hide-descendants"); with one, the title is itsaccessibilityLabel. There is no<title>element.
src/react-native/index.tsx, compiled by tsc in the build and type-checked against
react-native-svg's own types by npm run typecheck. tests/react-native.test.ts compiles it with
esbuild and renders three icons with react-dom/server. In that test, a stand-in for
react-native-svg renders each component as a host element named after it, because the real
package needs native modules that do not load in Node.
reactNative, listed in icon-browser's format registry since schema 1.5.0 and required by the registry
guard (tests/registry.test.ts).