react-native-css

2.1.2 • Public • Published

Babel-plugin

The awesome @danilosterrapid7 create a babel-plugin for React-native-css:

https://www.npmjs.com/package/babel-plugin-react-native-sass-classname

react-native-css Circle CI NPM

React-native-css turns valid CSS into the Facebook subset of CSS.

Version 2

With version 2 come new changes:

  • Remove sass/scss support, this is a huge overhead for little benefit.
  • No CLI, we believe that this is an unnecessary context switch
  • NO I/O, no longer writing files, we do everything at runtime.

if you still want access to the the old implementation, please check v1 branch.

Install

yarn add react-native-css
npm install react-native-css --save

Example

Given the following CSS:

import RNC from 'react-native-css';
 
RNC`
  description {
    margin-bottom: 20px;
    font-size: 18px;
    text-align: center;
    color: #656656;
  }
 
  container {
    padding: 30px;
    margin-top: 65px;
    align-items: center;
    display: block;
  }
`
 

React-native-css will generate to the following:

{"description":{"marginBottom":20,"fontSize":18,"textAlign":"center","color":"#656656"},"container":{"padding":30,"marginTop":65,"alignItems":"center"}}

Usage

import RNC from 'react-native-css';
 
class SearchPage extends Component {
  render() {
    const { color, fontSize } = this.props;
      const styles = RNC`
        description {
          margin-bottom: 20px;
          font-size: ${fontSize}
          text-align: center;
          color: ${color}
        }
 
        container {
          padding: 30px;
          margin-top: 65px;
          align-items: center;
          display: block;
        }
      `;
 
    return (
      <View style={styles.container}>
        <Text style={styles.description}>
            Search!
        </Text>
      </View>
    );
  }
}
 

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.1.213latest

Version History

VersionDownloads (Last 7 Days)Published
2.1.213
2.1.00
2.1.10
2.0.70
2.0.60
2.0.50
2.0.40
2.0.30
2.0.20
2.0.00
1.2.550
1.2.541
1.2.521
1.2.510
1.2.501
1.2.490
1.2.480
1.2.470
1.2.461
1.2.450
1.2.441
1.2.430
1.2.420
1.2.411
1.2.401
1.2.391
1.2.380
1.2.370
1.2.360
1.2.350
1.2.341
1.2.330
1.2.311
1.2.301
1.2.290
1.2.280
1.2.270
1.2.260
1.2.250
1.2.240
1.2.231
1.2.220
1.2.210
1.2.200
1.2.190
1.2.181
1.2.170
1.2.160
1.2.151
1.2.140
1.2.130
1.2.120
1.2.110
1.2.100
1.2.90
1.2.81
1.2.70
1.2.60
1.2.50
1.2.40
1.2.30
1.2.21
1.2.10
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.31
1.0.20
1.0.10
1.0.01

Package Sidebar

Install

npm i react-native-css

Weekly Downloads

26

Version

2.1.2

License

MIT

Last publish

Collaborators

  • marklawlor