# react-native-component-styled

> A React Native component styled

Latest version **2.1.0** (published 2022-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-component-styled
pnpm add react-native-component-styled
yarn add react-native-component-styled
bun add react-native-component-styled
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2022-01-15 |
| First published | 2022-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yves Kouayip |
| Maintainers | ykam |
| Keywords | react, react native, style, styled, mobile, android, appel, ios |

## Links

- npm: https://www.npmjs.com/package/react-native-component-styled
- Repository: https://github.com/kouayip/react-native-styled
- Homepage: https://github.com/kouayip/react-native-styled#readme
- Issues: https://github.com/kouayip/react-native-styled/issues
- npm.io page: https://npm.io/package/react-native-component-styled

## 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

- 2.1.0 (latest) — 2022-01-15
- 2.0.5 — 2022-01-15
- 2.0.4 — 2022-01-14
- 2.0.3 — 2022-01-14
- 2.0.2 — 2022-01-14
- 2.0.1 — 2022-01-13
- 2.0.0 — 2022-01-13

## README

# React Native Component Styled

A React Native component styled.

## Installation

```bash
npm i react-native-component-styled
```

## Usage


Use Styled to create and style your react native component.

```tsx
import styled from "react-native-component-styled";

const App = () => (
    <View>
        <Title size={26}>Welcome</Title>
        <Title size={14} color="grey">to react styled</Title>
    </View>
);

const Title = styled.Text<{size: number, color?: string}>({
    fontSize: props => props.size,
    color: props => props.color ?? "black",
    textTransform: 'uppercase',
    textAlign: 'center',
})
```
Define and use custom themes

```tsx
import styled, {ThemeProvider, LayoutContainer} from 'react-native-component-styled';

const App = () => (
    <LayoutContainer defaultMode="light">
        {({mode}) => (
            <ThemeProvider mode={mode} theme={themes[mode]}>
                <SafeAreaView>
                    <StatusBar
                        animated
                        barStyle={mode === 'light' ? 'light-content' : 'dark-content'}
                    />
                    <View>
                        <Title textTransform="uppercase">Welcome</Title>
                    </View>
                </SafeAreaView>
            </ThemeProvider>
        )}
    </LayoutContainer>
);

const Title = styled.Text<{textTransform?: 'uppercase' | 'lowercase'}>({
    textTransform: props => props.textTransform ?? 'uppercase',
    color: props => props.theme.colors.blue,
    fontSize: props => props.theme.largeTitle.fontSize,
    fontFamily: props => props.theme.largeTitle.fontFamily,
    lineHeight: props => props.theme.largeTitle.lineHeight,
});
```
Declare your own theme

```tsx
import 'react-native-component-styled';

declare module 'react-native-component-styled' {
    export interface Theme {
        colors: {
            primary: string;
            blue: string;
        };
        fonts: {
            largeTitle: {
                fontFamily: string;
                fontSize: number;
                lineHeight: number;
            };
        };
    }
}
```

implement your declared theme

```tsx
import {Theme} from 'react-native-component-styled';

const lightTheme: Theme = {
  colors: {
    primary: '#FF002E',
    blue: '#4096FE',
  },
  fonts: {
    largeTitle: {fontFamily: 'Roboto-Black', fontSize: 40, lineHeight: 38},
  },
};

export default lightTheme;
```

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