# react-native-style-prop-type

> A React PropType for React Native styles

Latest version **1.0.3** (published 2023-06-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-style-prop-type
pnpm add react-native-style-prop-type
yarn add react-native-style-prop-type
bun add react-native-style-prop-type
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-06-22 |
| First published | 2023-05-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | JP Strydom |
| Maintainers | jpstrydom |
| Keywords | React, ReactNative, PropType |

## Links

- npm: https://www.npmjs.com/package/react-native-style-prop-type
- Repository: https://github.com/JPStrydom/React-Native-Style-Prop-Type
- Homepage: https://github.com/JPStrydom/React-Native-Style-Prop-Type#readme
- Issues: https://github.com/JPStrydom/React-Native-Style-Prop-Type/issues
- npm.io page: https://npm.io/package/react-native-style-prop-type

## Dependencies (1)

- [react-style-proptype](https://npm.io/package/react-style-proptype.md) ^3.2.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2023-06-22
- 1.0.2 — 2023-05-12
- 1.0.1 — 2023-05-12
- 1.0.0 — 2023-05-12

## README

# React Native Style Prop Type

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

[![js-standard-style](https://cdn.rawgit.com/standard/standard/master/badge.svg)](http://standardjs.com)

## Description

Validate React Native styles by ensuring the style keys are valid React Native style properties.

- Required prop type validation is supported, similar to the built-in prop types.
  - `ReactNativeStylePropType.isRequired`
- Style array validation is also supported.
  - `style={[styles.textStyle1, styles.textStyle2]}`

## Usage

```jsx
import { StyleSheet, Text, View } from 'react-native';
import ReactNativeStylePropType from 'react-native-style-prop-type';

const Component = ({style, textStyle}) => (
  <View style={style}>
    <Text style={textStyle}>My Component</Text>
  </View>
);

Component.propTypes = {
  style: ReactNativeStylePropType.isRequired,
  textStyle: ReactNativeStylePropType
};

const Page = () => (
  <Component style={styles.style} textStyle={[styles.textStyle1, styles.textStyle2]} />
);

const styles = StyleSheet.create({
  style: { ... },
  textStyle1: { ... },
  textStyle2: { ... }
})
```

## Installation

```shell
npm i react-native-style-prop-type -S
```

## Special Thanks

Thanks to [Frankie Bagnardi](https://github.com/brigand) for creating the original [react-style-proptype](https://www.npmjs.com/package/react-style-proptype) package which this package builds on top of.

---
_Source: https://npm.io/package/react-native-style-prop-type · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
