All Projects → kristerkari → React Native Css Modules

kristerkari / React Native Css Modules

Licence: mit
Style React Native components using CSS, PostCSS, Sass, Less or Stylus.

Programming Languages

stylus
462 projects

Projects that are alternatives of or similar to React Native Css Modules

Rollup Plugin Postcss
Seamless integration between Rollup and PostCSS.
Stars: ✭ 507 (+144.93%)
Mutual labels:  sass, less, postcss, css-modules
Rollup Plugin Styles
🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
Stars: ✭ 116 (-43.96%)
Mutual labels:  sass, less, postcss, css-modules
Reset Css
An unmodified* copy of Eric Meyer's CSS reset. PostCSS, webpack, Sass, and Less friendly.
Stars: ✭ 244 (+17.87%)
Mutual labels:  sass, less, postcss
multi-brand-colors
Multi Brand Colors with support for CSS/CSS-Vars/SCSS/SASS/Stylus/LESS/JSON
Stars: ✭ 26 (-87.44%)
Mutual labels:  less, postcss, css-variables
Webpack Encore
A simple but powerful API for processing & compiling assets built around Webpack
Stars: ✭ 1,975 (+854.11%)
Mutual labels:  sass, less, postcss
Static Site Boilerplate
A better workflow for building modern static websites.
Stars: ✭ 1,633 (+688.89%)
Mutual labels:  sass, less, postcss
Prejss
Get the power of PostCSS with plugins in your JSS styles. 🎨 Just put CSS into JS and get it as JSS object.
Stars: ✭ 238 (+14.98%)
Mutual labels:  sass, less, postcss
webpack-typescript-react
Webpack 5 boilerplate with support of most common loaders and modules (see tags and description)
Stars: ✭ 185 (-10.63%)
Mutual labels:  less, postcss, css-modules
Kit
ReactQL starter kit (use the CLI)
Stars: ✭ 232 (+12.08%)
Mutual labels:  sass, less, postcss
Kratos Boilerplate
🔥 A simple boilerplate for creating statics PWA using Webpack, Pug, PostCSS and CSS Modules
Stars: ✭ 308 (+48.79%)
Mutual labels:  sass, postcss, css-modules
Stylelint
A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
Stars: ✭ 9,350 (+4416.91%)
Mutual labels:  sass, less, postcss
Cessie
Transpile your CSS bundle to support CSS variables, calc, and future CSS for legacy browsers.
Stars: ✭ 81 (-60.87%)
Mutual labels:  sass, less, postcss
Vscode Stylelint
A Visual Studio Code extension to lint CSS/SCSS/Less with stylelint
Stars: ✭ 260 (+25.6%)
Mutual labels:  sass, less, postcss
Moo Css
模块化面向对象的css写法规范策略。适用于大中小型C端项目样式开发,旨在提高开发和维护效率。
Stars: ✭ 79 (-61.84%)
Mutual labels:  sass, less, css-modules
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+785.51%)
Mutual labels:  sass, less, postcss
Svg Sprite
SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)
Stars: ✭ 1,648 (+696.14%)
Mutual labels:  sass, less
Frasco
Quick starter for Jekyll including full setup for Sass, PostCSS, Autoprefixer, stylelint, Webpack, ESLint, imagemin, Browsersync, etc.
Stars: ✭ 123 (-40.58%)
Mutual labels:  sass, postcss
Gulp Starter Kit
A simple Gulp 4 Starter Kit for modern web development.
Stars: ✭ 134 (-35.27%)
Mutual labels:  sass, less
React Typescript Webpack2 Cssmodules Postcss
Simple Starter Template for React, TypeScript, postCSS, ITCSS, CSS-Modules, Webpack and Live Reloading (React Hot Loader 3)
Stars: ✭ 117 (-43.48%)
Mutual labels:  postcss, css-modules
Fast
Develop, build, deploy, redeploy, and teardown frontend projects fast.
Stars: ✭ 126 (-39.13%)
Mutual labels:  sass, postcss

React Native CSS modules

Style React Native components using CSS, PostCSS, Sass, Less or Stylus.

Quick links: FeaturesDocumentationExampleDevelopmentFAQ

Features

Examples

Using React Native CSS modules works almost the same way as using CSS modules with a Web React project, but there are some limitations. There is no support complex CSS selectors. Only simple CSS class selector (e.g. .myClass) is supported. React Native also only supports a subset of browser's CSS properties for styling.

For more info about the differences between using CSS modules in Web and React Native, have a look at this explanation in the FAQ.

Basic example using Sass

App.scss

.container {
  flex: 1;
  justify-content: center;
  align-items: center;
}

.blue {
  color: blue;
}

.blueText {
  @extend .blue;
  font-size: 18px;
}

App.js

import React from "react";
import { Text, View } from "react-native";
import styles from "./App.scss";

const App = () => (
  <View className={styles.container}>
    <Text className={styles.blueText}>Blue text</Text>
  </View>
);
export default App;

CSS media queries and CSS viewport units

If you need CSS media queries or CSS viewport units, please have a look at the responsive CSS features setup guide.

.wrapper {
  height: 10vh;
  width: 10vw;
}

@media (min-width: 800px) {
  .wrapper {
    height: 20vh;
    width: 20vw;
  }
}

CSS variables

CSS variables are not supported by default, but you can add support for them by using PostCSS and postcss-css-variables plugin.

Please have a look at the CSS variables setup guide.

:root {
  --text-color: blue;
}

.blue {
  color: var(--text-color);
}

Exporting variables from CSS to Javascript

You might also need to share you variables from a CSS/Sass/Less/Stylus file to Javascript. To do that you can use the :export keyword:

colors.scss

$grey: #ccc;

:export {
  grey: $grey;
}

App.js

import React from "react";
import { Text, View } from "react-native";
import colors from "./colors.scss";
import styles from "./App.scss";

const App = () => (
  <View className={styles.container}>
    <Text className={styles.blueText} style={{ color: colors.grey }}>
      Grey text
    </Text>
  </View>
);
export default App;

Example Apps

Have a look at the example apps to see how you can use CSS modules for both React Native and Web using the same code.

Documentation

📚 Setup

📚 Other documentation

Development

To see which new features are being planned and what is in progress, please have a look at the development board.

If you want to suggest a new feature or report a bug, please open a new issue.


Special thanks

The idea for React Native CSS modules comes from these projects that have made a lot of work for supporting CSS and CSS modules in React Native: css-to-react-native and react-native-sass-classname. A big thanks to them!


License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].