# @emotion/native

> Style and render React Native components using emotion

Latest version **11.11.0** (published 2023-05-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @emotion/native
pnpm add @emotion/native
yarn add @emotion/native
bun add @emotion/native
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; popular repo.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 11.11.0 |
| Published | 2023-05-06 |
| First published | 2018-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 33.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18020 |
| Maintainers | emmatown, tkh44, emotion-release-bot, andarist |
| Keywords | styles, emotion, react, css, css-in-js, native |

## Links

- npm: https://www.npmjs.com/package/@emotion/native
- Repository: https://github.com/emotion-js/emotion.git#main
- Homepage: https://emotion.sh
- Issues: https://github.com/emotion-js/emotion/issues
- npm.io page: https://npm.io/package/@emotion/native

## Dependencies (1)

- [@emotion/primitives-core](https://npm.io/package/@emotion/primitives-core.md) ^11.11.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 11.11.0 (latest) — 2023-05-06
- 11.0.0-rc.0 (rc) — 2020-10-11
- 11.0.0-next.19 (next) — 2020-10-03
- 11.10.6 — 2023-02-16
- 11.10.0 — 2022-07-31
- 11.9.3 — 2022-06-12
- 11.0.0 — 2020-11-12
- 11.0.0-next.18 — 2020-09-20
- 11.0.0-next.17 — 2020-09-09
- 11.0.0-next.16 — 2020-09-08
- 11.0.0-next.15 — 2020-08-18
- 11.0.0-next.14 — 2020-08-01
- 11.0.0-next.13 — 2020-06-22
- 11.0.0-next.12 — 2020-03-17
- 11.0.0-next.11 — 2020-01-16
- … 44 more at https://npm.io/package/@emotion/native/versions

## README

# @emotion/native

> Style and render React Native components using emotion

## Install

```
npm install @emotion/react @emotion/native
```

or if you use yarn

```
yarn add @emotion/react @emotion/native
```

This package also depends on `react`, `react-native` and `prop-types` so make sure you've them installed.

## Example

```js
import React from 'react'
import { AppRegistry } from 'react-native'
import styled, { css } from '@emotion/native'

const Container = styled.View`
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 50px;
`

const Description = styled.Text({
  color: 'hotpink'
})

const Image = styled.Image`
  padding: 40px;
`

const emotionLogo = 'https://cdn.rawgit.com/emotion-js/emotion/main/emotion.png'

class App extends React.Component {
  render() {
    return (
      <Container
        style={css`
          border-radius: 10px;
        `}
      >
        <Description style={{ fontSize: 45, fontWeight: 'bold' }}>
          Emotion Primitives
        </Description>
        <Image
          source={{
            uri: emotionLogo,
            height: 150,
            width: 150
          }}
        />
      </Container>
    )
  }
}

AppRegistry.registerComponent('ExampleApp', () => App)
```

## Theming

Use `@emotion/react` for theming support.

```js
import React from 'react'
import styled, { css } from '@emotion/native'
import { ThemeProvider } from '@emotion/react'

const theme = {
  color: 'hotpink',
  backgroundColor: 'purple'
}

const Container = styled.View`
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 50px;
  border: 5px solid red;
  background-color: ${props => props.theme.backgroundColor};
`

const Description = styled.Text({
  color: 'hotpink'
})

const Image = styled.Image`
  padding: 40px;
`

const emotionLogo = 'https://cdn.rawgit.com/emotion-js/emotion/main/emotion.png'

class App extends React.Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <Container
          style={css`
            border-radius: 10px;
          `}
        >
          <Description style={{ fontSize: 45, fontWeight: 'bold' }}>
            Emotion Primitives
          </Description>
          <Image
            source={{
              uri: emotionLogo,
              height: 150,
              width: 150
            }}
          />
        </Container>
      </ThemeProvider>
    )
  }
}
```

## Gotchas

- Note that the `flex` property works like CSS shorthand, and not the legacy `flex` property in React Native. Setting `flex: 1` sets `flexShrink` to `1` in addition to setting `flexGrow` to `1` and `flexBasis` to `0`.

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