react-native-css 0,1,1

Style React-Native components with css and built in support for SASS/SCSS

We are looking for additional contributors

Raise and issue and I will add you. After a PR.

react-native-css (and SCSS) Circle CI NPM

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

Install

Global

npm install react-native-css -g

Command Line Interface

React-native-css comes with a cli and you can watch a file and compile it.

# example 1
react-native-css -i INPUT_CSS_FILE -o OUTPUT_JS_FILE --watch
# example 2
react-native-css -i INPUT_CSS_FILE -o OUTPUT_JS_FILE --watch --pretty
# example 3
react-native-css INPUT_CSS_FILE OUTPUT_JS_FILE -w
react-native-css -i style.css -o style.js -w

Flags - “-w” or “–watch” - watch for changes and recompile. - “-i” takes a input (optional) - “-o” takes an output path (optional) - “-p” or “–pretty” - pretty print the resulting compiled output - “-l” or “–literal” - generates a javascript literal object without StyleSheet.create wrapper

Screenshot

the workflow

Example

Given the following CSS:

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:

// style.js
module.exports = require('react-native').StyleSheet.create(
  {"description":{"marginBottom":20,"fontSize":18,"textAlign":"center","color":"#656656"},"container":{"padding":30,"marginTop":65,"alignItems":"center"}}
  );

You can make use of –literal argument and instead it will generate:

// style.js
module.exports = {
  "description":{"marginBottom":20,"fontSize":18,"textAlign":"center","color":"#656656"},"container":{"padding":30,"marginTop":65,"alignItems":"center"}
  }

Usage

// require the generated style file
var styles = require('./style.js')
 //{"description":{"marginBottom":20,"fontSize":18,"textAlign":"center","color":"#656656"},"container":{"padding":30,"marginTop":65,"alignItems":"center"}}


class SearchPage extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.description}>
        Buy
        </Text>

      </View>
    );
  }
}

Related Repositories

react-native-css

react-native-css

Style React-Native components with css and built in support for SASS/SCSS ...

react-mix

react-mix

Base on react-native, plan to support all CSS gramma, and all js dom event, and all h5 framework, our object is write once, run anywhere! ...

native-css

native-css

Convert pure CSS to React Style or javascript literal objects. ...

uranium

uranium

Universal css-in-js media queries for React Native and React ...

react-native-tableview-simple

react-native-tableview-simple

Flexible and lightweight React Native component for UITableView made with pure CSS ...


Top Contributors

sabeurthabti alexmick caiosba alfonsodev davidgruebl DrMabuse23 originalgremlin ExplodingCabbage jeffpearce martnu tylermcginnis irfaan soliury