Skip to content

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

Notifications You must be signed in to change notification settings

ivanbogdanov/react-native-css

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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"}}
  );

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>
    );
  }
}

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.4%
  • Shell 0.6%