Android vector drawables in React Native
npm install @klarna/react-native-vector-drawable> Android vector drawables in React Native.
[![Build Status][ci-image]][ci-url]
[![License][license-image]][license-url]
[![Developed at Klarna][klarna-image]][klarna-url]
An alternative to react-native-svg with 5x faster renders, lighter bundle and built in dark mode support.
``sh`
yarn add @klarna/react-native-vector-drawable
This library supports React Native New Architecture (aka Fabric). To use this library with your Fabric application, you have to:
1. Add latest @klarna/react-native-vector-drawableRCT_NEW_ARCH_ENABLED=1 pod install
2. on iOS:
- Install pods using – this is the same command you run to prepare a Fabric build but you also need to run it after a new native library gets added.newArchEnabled=true
3. on Android:
- There are no additional steps required so long you app is configured to build with Fabric – this is typically configured by setting in gradle.properties file in your project.
`js
import VectorDrawable from '@klarna/react-native-vector-drawable';
const Component = () => (
style={{ width: 50, height: 50, tintColor: 'blue' }}
/>
);
`
| Prop | Description | Default |
| ------------------ | -------------------------------------------------------- | ------- |
| resourceName | Name of the Android vector drawable resource. | _None_ |
| style | See _Style props_. Note: border props are not supported. | _None_ |
#### Style props
| Prop | Description | Default |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| resizeMode | Determines how to resize the image when the frame doesn't match the raw image dimensions. Possible values are cover, contain, stretch and center | cover |tintColor
| | Changes the color of all the non-transparent pixels to the tintColor. | _None_ |
See our guide on contributing.
See our changelog.
Update version in package.json` and merge to master. This will publish the package to NPM, create a draft release on GitHub and a version tag. Edit the release with additional information and publish it.
Copyright © 2022 Klarna Bank AB
For license details, see the LICENSE file in the root of this project.
[ci-image]: https://img.shields.io/badge/build-passing-brightgreen?style=flat-square
[ci-url]: https://github.com/klarna-incubator/react-native-vector-drawable/actions/
[license-image]: https://img.shields.io/badge/license-Apache%202-blue?style=flat-square
[license-url]: http://www.apache.org/licenses/LICENSE-2.0
[klarna-image]: https://img.shields.io/badge/%20-Developed%20at%20Klarna-black?labelColor=ffb3c7&style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAm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