# react-simple

> simple style only components for the web & native

Latest version **1.2.3** (published 2017-02-23) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-simple
pnpm add react-simple
yarn add react-simple
bun add react-simple
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2017-02-23 |
| First published | 2017-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Esa-Matti Suuronen |
| Maintainers | epeli |
| Keywords | react, react-native, css-in-js |

## Links

- npm: https://www.npmjs.com/package/react-simple
- Repository: https://github.com/epeli/react-simple
- Homepage: https://github.com/epeli/react-simple#readme
- Issues: https://github.com/epeli/react-simple/issues
- npm.io page: https://npm.io/package/react-simple

## Dependencies (6)

- [jest](https://npm.io/package/jest.md) ^19.0.0
- [glamor](https://npm.io/package/glamor.md) ^2.20.22
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [deepmerge](https://npm.io/package/deepmerge.md) ^1.3.2
- [classnames](https://npm.io/package/classnames.md) ^2.2.5
- [babel-plugin-display-name-custom](https://npm.io/package/babel-plugin-display-name-custom.md) ^0.1.3

## 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.2.3 (latest) — 2017-02-23
- 1.2.2 — 2017-02-21
- 1.2.1 — 2017-02-21
- 1.2.0 — 2017-02-18
- 1.1.0 — 2017-02-18
- 1.0.0 — 2017-02-15
- 0.0.5 — 2017-02-13
- 0.0.4 — 2017-02-13
- 0.0.3 — 2017-02-13
- 0.0.2 — 2017-02-13
- 0.0.1 — 2017-02-12

## README

# react-simple

simple style only components for the web & native

install

    yarn add react-simple  

usage

```js
import simple from "react-simple";

const Button = simple("button", {
    padding: 10,
});
// <Button>click</Button>


// extend existing components
const RedButtonWithPadding = simple(Button, {
    backgroundColor: "red",
});


// reuse styles for different component types
const LinkWithPadding = simple(Button.create("a"), {
    textDecoration: "none",
});
// <LinkWithPadding href="/link">link</LinkWithPadding>


// simple style toggles
const Button = simple("button", {
    padding: 10,
}, {
    rounded: {
        borderRadius: 5,
    },
});
// <Button rounded>click</Button>


// can extend 3rd party commponents too
import {Link} from "react-router";

const RedLink = simple(Link, {
    backgroundColor: "red",
});
// <Link to="/hello">Hello</Link>
```

here's some [example code](https://github.com/epeli/react-simple/blob/master/demo/index.js) using it


The css-in-js engine is [glamor][] which means following features:

- automatic vendor prefixes
- pseudo :classes/::elements
- media queries
- css animations
- server side rendering
- and more: checkout the [glamor docs][glamor]

glamor `css`function can be imported with `import {css} from "react-simple"` when needed

[glamor]: https://github.com/threepointone/glamor

# react-native

To use in React Native import `simple` from `react-simple/native`. Anything can be passed
as styles what can be passed to `StyleSheet.create()`.

```js
import {View} from "react-native";
import simple from "react-simple/native";

const Box = simple(View, {
    flex: 1,
    border: "1px solid black",
});
```

# style attribute

To put styles in the style attribute import `simple` from `react-simple/inline`

```js
import simple from "react-simple/inline";

const Box = simple("div", {
    padding: 10,
    border: "1px solid black",
});
```

Generally this should not be used but there is one important use case: HTML Emails.

To render a HTML template use [ReactDOMServer](https://facebook.github.io/react/docs/react-dom-server.html)

```js
import ReactDOMServer from "react-dom/server";
const html = ReactDOMServer.renderToStaticMarkup(<Box>hello email</Box>);
```

# babel plugin

> This is totally optional!

By default components created using `simple` do not get proper component names
which means they won't get very helpful names in [React Developer Tools][devtools].
This can be mitigated using the bundled `react-simple/babel` Babel plugin which infers
the component names from the variable declarations.

[devtools]: https://github.com/facebook/react-devtools

The use it add `react-simple/babel` to your `.babelrc`

```json
{
    "presets": ["es2015", "react"],
    "plugins": [
        "react-simple/babel"
    ]
}
```

In practice this means that instead of

![default](https://raw.githubusercontent.com/epeli/react-simple/master/demo/assets/simple-default.png)

you will get

![default](https://raw.githubusercontent.com/epeli/react-simple/master/demo/assets/simple-babel.png)

it will also add class names corresponding the component names
so even without the React specfic devtools you will get better insights

![default](https://raw.githubusercontent.com/epeli/react-simple/master/demo/assets/simple-dom.png)

You can see it in action at https://epeli.github.io/react-simple/ 

Source code is under `demo/`

This feature is powered by [babel-plugin-display-name-custom][].

[babel-plugin-display-name-custom]: https://github.com/epeli/babel-plugin-display-name-custom

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