A plugin for Babel v6 which transforms inline styles defined in JavaScript modules into class names so they become available to, e.g. the `className` prop of React elements. While transforming, the plugin processes all JavaScript style definitions found and bundles them up into a CSS file, ready to be requested from your web server.

Overview

babel-plugin-css-in-js

build status code climate test coverage npm version

A plugin for Babel v6 which transforms inline styles defined in JavaScript modules into class names so they become available to, e.g. the className prop of React elements. While transforming, the plugin processes all JavaScript style definitions found and bundles them up into a CSS file, ready to be requested from your web server.

babel-plugin-css-in-js works seamlessly on both client and server. It has built-in support for media queries, pseudo-classes, attribute selectors, and theming. The plugin's options allow you to configure vendor-prefixing, minification, and class name compression.

If you're impatient, visit the live demo. The source code for it can be found in the example directory.

Example

In order for the plugin to work, in your components, surround each inline style specification with a module-level cssInJS() function call. This provides a hook for the plugin to process the first argument given to the call and then replace it with an object literal containing the resulting class names as values.

In

<Button className={styles.button} />

var styles = cssInJS({
  button: {
    padding: 5,
    backgroundColor: "blue"
  }
});

Out

JavaScript:

<Button className={styles.button} />

var styles = {
  button: "example_js_styles_button"
};

CSS:

.example_js_styles_button {
  padding: 5px;
  background-color: blue;
}

The stylesheet specification format is explained further down.

Note the return value of cssInJS(...) must be assigned to a variable. The name of the variable is used to distinguish multiple cssInJS calls within a file.

Installation

Install via npm:

$ npm install babel-plugin-css-in-js --save-dev

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["css-in-js"]
}

Via CLI

$ babel  --plugins css-in-js  script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['css-in-js']
});

Options

The plugin allows configuration of several parameters which control the generated CSS. You can pass options to the plugin by using a two-element array when adding the plugin. For instance, using .babelrc:

{
  "presets": [
    "es2015",
    "react"
  ],
  "plugins": [
    "foo-plugin",
    ["css-in-js", { "vendorPrefixes": true, "bundleFile": "public/bundle.css" }]
  ]
}

Available options:

Option Default Description
vendorPrefixes false If true, the generated CSS is run through autoprefixer to add vendor prefixes to the rules. If set to an object, it is passed to autoprefixer as options argument.
minify false Set to true to enable minification of the generated CSS. The popular clean-css package is used for this.
compressClassNames false Set to true to shorten/obfuscate generated CSS class names. A class name like "my_file-my_styles_var-my_name" will so be converted to, e.g., "_bf".
mediaMap {} This allows you to define media query shortcuts which are expanded on building the CSS. Example: using { phone: "media only screen and (max-width: 640px)" } as value for this option and a stylesheet spec having "@phone" as a key, that key will be translated to @media only screen and (max-width: 640px) in the final CSS.
context null If set to an object, each identifier found on the right-hand side of a style rule is substituted with the corresponding property value of this object. If set to a file path, the file is require'd and the exported object is used as stylesheet context.
cacheDir tmp/cache/ If you set the compressClassNames option to true, the class name cache will be persisted in a file in this directory.
bundleFile bundle.css All generated CSS is bundled into this file.
identifier cssInJS The name used for detecting inline styles to transform.
transformOptions { presets: ['es2015'] } Babel options to use when passing a function as argument (instead of an object) to cssInJS().

Stylesheet Specification Format

Here's what you can put inside the parentheses of cssInJS(...).

Simple Styles

{
  myButton: {
    border: 'solid 1px #ccc',
    backgroundColor: 'lightgray',
    display: 'inline-block'
  },

  myInput: {
    width: '100%',
    // ... etc.
  }
}

An inline style is not specified as a string. Instead it is specified with an object whose properties form the CSS ruleset for that style. A property's key is the camelCased version of the rule name, and the value is the rule's value, usually a string.

There's also a shorthand notation for specifying pixel values, see this React tip for more details.

Pseudo-Classes and Attribute Selectors

{
  myButton: {
    border: 'solid 1px #ccc',
    backgroundColor: 'lightgray',
    display: 'inline-block',
    cursor: 'pointer',

    ':focus': {
      borderColor: '#aaa'
    },

    ':hover': {
      borderColor: '#ddd',

      ':active': {
        borderColor: '#eee'
      }
    },

    '[disabled]': {
      cursor: 'not-allowed',
      opacity: .5,

      ':hover': {
        backgroundColor: 'transparent'
      }
    }
  }
}

As you can see, pseudo-classes and attribute selectors can be nested arbitrarily deep. But you don't have to use nesting. Here is the example from above in the un-nested version:

{
  myButton: {
    border: 'solid 1px #ccc',
    backgroundColor: 'lightgray',
    display: 'inline-block',
    cursor: 'pointer'
  },
  'myButton:focus': {
    borderColor: '#aaa'
  },
  'myButton:hover': {
    borderColor: '#ddd'
  },
  'myButton:hover:active': {
    borderColor: '#eee'
  },
  'myButton[disabled]': {
    cursor: 'not-allowed',
    opacity: .5
  },
  'myButton[disabled]:hover': {
    backgroundColor: 'transparent'
  }
}

Media Queries

{
  myButton: {
    border: 'solid 1px #ccc',
    // ...
  },

  myInput: {
    width: '100%',
    // ...
  },

  '@media only screen and (max-width: 480px)': {
    myButton: {
      borderWidth: 0
    },

    myInput: {
      fontSize: 14
    }
  },

  '@media only screen and (max-width: 768px)': {
    myButton: {
      borderWidth: 2,

      ':hover': {
        borderWidth: 3
      }
    }
  }
}

Media queries can appear at the top-level (as shown above) or nested in the style:

{
  myButton: {
    border: 'solid 1px #ccc',

    '@media only screen and (max-width: 480px)': {
      borderWidth: 0,

      ':active': {
        borderColor: 'blue'
      }
    },

    '@media only screen and (max-width: 768px)': {
      // ...
    }
  }
}

Given you set { phone: 'media only screen and (max-width: 480px)', tablet: 'media only screen and (max-width: 768px)' } as mediaMap option for the transformation, the above spec can be simplified to:

{
  myButton: {
    border: 'solid 1px #ccc',

    '@phone': {
      borderWidth: 0,

      ':active': {
        borderColor: 'blue'
      }
    },

    '@tablet': {
      // ...
    }
  }
}

Expressions in Style Rules

You can do simple arithmetic and string concats on the right-hand side of style rules. Each identifier found is substituted with the corresponding property value of the context object provided as option.

Example for a given context { MyColors: { green: '#00FF00' }, myUrl: 'path/to/image.png' }:

{
  myButton: {
    color: MyColors.green,
    borderWidth: 42 + 'px',
    backgroundImage: 'url(' + myUrl + ')'
  }
}

Basic theming via nesting within global selectors

You can nest your styles within another selector which is prefixed with $. These "global" selectors will be prepended (without the dollar sign of course) to the styles when generating the CSS. Nested styles also support pseudo-classes, attribute selectors and media queries. Example:

{
  myButton: {
    color: 'black'
  },
  '$body.red-theme': {
    myButton: {
      color: 'red'
    }
  },
  '$.blue >': {
    myButton: {
      color: 'blue';
    }
  }
}

CSS output (assuming b1 will become the generated class name for myButton):

.b1 {
  color: black;
}

body.red-theme .b1 {
  color: red;
}

.blue > .b1 {
  color: blue;
}

Global Styles

To opt out of the autogenerated class names and use global CSS selectors instead, you can prefix a selector with $. The selector will be passed through unchanged to the CSS.

This is useful to define reset, site-wide, or legacy styles without having to use a separate pipeline.

{
  '$html, body': {
    margin: 0,
    padding: 0,
  },

  '$.small-caps': {
    fontVariant: 'small-caps',
    fontFeatureSettings: '"smcp"',
  },

  '$.legacy-button': {
    border: '1px solid gray',
  },
}

CSS:

html, body {
  margin: 0;
  padding: 0;
}

.small-caps {
  font-variant: small-caps;
  font-feature-settings: "smcp";
}

.legacy-button {
  border: 1px solid gray;
}

Global selectors will be omitted in the JS object that cssInJS returns.

Dynamic Styles using Function Expressions

In order to write style rules dynamically, you can use function expressions. A function gives more freedom than an object. It receives a context object as first parameter. With this, you can do any programmatic operation, such as conditionals or even iterating over something. ES6 syntax is also available.

The function will be executed in a completely blocked Node.js VM sandbox environment, reveiving only the context object. Therefore you cannot require or import other modules in its body, or access references outside its scope.

Another thing to keep in mind is that the bundle file extraction and the JS file transformation will be based on the function's return value (which should be an object conforming to the Stylesheet Specification Format).

Here's an example that generates a stylesheet object based on platform, theme and env information passed via the context argument:

const style = cssInJS(function(context) {
  const { env, platform, theme } = context;

  const buttonSize = 100;
  let marginList = [10, 8, 10, 8];

  if (platform === 'iOS') {
    marginList = marginList.map(v => v - 2);
  }

  return {
    button: {
      width: buttonSize,
      margin: marginList.map(v => v + 'px').join(' '),
      color: platform === 'Android' ? 'red' : 'blue',
      border: env === 'development' ? '2px solid red' : 'none'
    },

    buttonBox: {
      backgroundColor: theme === 'dark' ? 'black' : 'white';
    }
  };
});

The context argument in the above code can be passed from, e.g., a Webpack babel loader setting like this:

// webpack.config.js

const env      = process.env.NODE_ENV || 'test';
const platform = process.env.PLATFORM || 'desktop';
const theme    = process.env.THEME    || 'dark';

const babelPluginCSSInJS = [
  ["css-in-js", {
    compressClassNames: env === 'production',
    vendorPrefixes: true,

    // generate a CSS bundle for each platform and theme
    bundleFile: `build/bundle.${theme}.${platform}.css`,

    context: { env, platform, theme },
  }],
];

module.exports = {
  // ...
  module: {
    loaders: [{
      test: /\.js$/,
      loader: 'babel',
      query: {
        presets: ['es2015', 'react'],
        plugins: [
          babelPluginCSSInJS,
        ]
      },
    }],
  },
  // ...
}

Example

If you just want to see some example output for a file, head over to this repo's quick example. There you will find the code for a simple button component together with its transformed version and CSS file (both with and without compressed class names).

The code for a more sophisticated example can be found in the repo's example directory. After cloning this repo, see the example's README for more info on how to run it.

Caveats

  • Just using var styles = cssInJS(...) in your React modules and skipping the transformation step won't work. It's the transformation that is responsible for a) generating the real CSS, and b) turning your cssInJS(...) calls into object literals holding the CSS class names so you can do <foo className={styles.bar} /> without breaking React. But you are transpiling your JavaScript anyway to get these cool new ES2015 features, aren't you?
  • Apart from simple arithmetic and string concats, a stylesheet specification cannot contain advanced dynamic stuff, because although the transformer parses the source input, it is not compiled. If you really need to add truly dynamic styles, that's what the style attribute/prop was made for. style also has the positive side-effect of taking precedence over class names.

Contributing

  1. Fork it ( https://github.com/martinandert/babel-plugin-css-in-js )
  2. Run npm install to install dependencies.
  3. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate: make test.
  4. Create your feature branch (git checkout -b my-new-feature)
  5. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or are fixing a bug, we need a test!
  6. Make the test pass.
  7. Commit your changes (git commit -am 'add some feature')
  8. Push to your fork (git push origin my-new-feature)
  9. Create a new Pull Request

License

Released under The MIT License.

Comments
  • Is there any support for sub-selectors currently?

    Is there any support for sub-selectors currently?

    Hello, I wonder if subselectors are supported at the moment, since either of following syntax seems to throw syntax errors,

    // Either 
    const classes = ({
      'wrapper title': {
        margin: 1,
      }
    })
    
    // Or
    const classes = ({
      'wrapper': {
        'title': {
          margin: 1,
        }
      }
    })
    

    Despite the second syntax being a SASS style and might not be the focus of this project, the first syntax actually belongs to CSS syntax and is quite useful, or actually irreplaceably necessary, in practice.

    opened by dkwingsmt 9
  • Support specific platform or theme?

    Support specific platform or theme?

    Suppose I have a below button style.

    const styles = cssInJS({
      button: {
        width: 57,
        height: 57,
      },
    })
    

    I wanna make some css properties changes on the specific platform ios.

    // case1)
    const styles = cssInJS({
      button: {
        width: __IOS__ ? 40 : 57,
        height: 57,
      },
    })
    

    or wanna make changes in some classes,

    // case2)
    const styles = cssInJS({
      button: __IOS__ ? {
        width: 40,
        height: 57,
      } : {
        width: 57,
        height: 57,
      }
    })
    

    In the above examples, __IOS__ will be defined by webpack definePlugin, or It will be just normal variable.

    Now, I have to add another class, like button_ios. but that way make a bundle with all classes even useless.

    Do you have any plan about that feature supporting specific platform or theme style using condition statement? If you are not available now, It wouldn't be easy to do, but I cound make a PR.

    opened by b6pzeusbc54tvhw5jgpyw8pwz2x6gs 8
  • nth-of-type example

    nth-of-type example

    For stuff like this in css

    p:nth-of-type(1) {} p:nth-of-type(2) {} p:nth-of-type(3) {}

    you basically need to create object with styling for every p and then attach it to that element? What's the best practice for this stuff?

    opened by DjordjePetrovic 5
  • Usage in a webpack dev environment

    Usage in a webpack dev environment

    I am wondering how one would go about setting a webpack dev environment up with this plugin? All my efforts have so far ended up with the styles of the last saved file overwriting the content of the bundled file.

    opened by Nimaear 5
  • Support function expression

    Support function expression

    To write dynamic style rules, now we can use FunctionExpression. This PR includes code change, some test code and added documentation. Also maybe two #9 #13 issues will be resolved by this PR. In my environment, all test case is passed.

    Thanks.

    opened by b6pzeusbc54tvhw5jgpyw8pwz2x6gs 3
  • Support global selectors

    Support global selectors

    This is an easy solution for #16. Any selector prefixed with $ is passed through to the generated CSS unchanged, and omitted in the resulting JS object.

    This allows for comma-separated lists of selectors as well, such as { '$html, body, .button': {} }, which is pretty useful when defining global stylesheets.

    An alternative solution would be to allow comma separated selectors everywhere, and requiring the prefixing of every selector individually ({ foo: {}, bar: {}, '$html, $body, $.button, foo, bar': {} }), but that would be a bigger change. Would love to hear thoughts on this.

    opened by steadicat 2
  • Support global style rules

    Support global style rules

    It would be great if it were an escape hatch that would allow you to specify global style rules in JS as well, without having to use a separate syntax and pipeline for it.

    There could be a special syntax that would opt a rule out of the selector rewriting. For example:

    const globalStyles = cssInJS({
      '$body': {margin: 0},
      '$.small-caps': {textTransform: 'uppercase', fontSize: '0.9%'},
    });
    

    This would inject the following into the generated stylesheet:

    body {margin: 0px}
    .small-caps {text-transform: uppercase; font-size: 0.9%}
    
    opened by steadicat 2
  • Is there any solution about universal app?

    Is there any solution about universal app?

    Recently, I'm working on the study about universal app like react-redux-universal-hot-example. As far as I know, in universal app, js files are loaded from different ways on each server and client side. Server side use the babel-register but client side use a bundle js file from webpack.

    I have a question. Assuming that my code state haven't changed and use the same babelrc and options, regardless of the loading method(babel-register or webpack), does babel-plugin-css-in-js always guarantee to create the same class name? Even when I use compressClassName option, always guarantee it?

    opened by b6pzeusbc54tvhw5jgpyw8pwz2x6gs 2
  • String value cannot be blank

    String value cannot be blank

    On this line of transformObjectExpressionIntoStyleSheetObject, the string value is checked to see if it is blank, which is currently matching all whitespace characters.

    This disallows CSS that looks like this:

    const stylesheet = cssInJS({
        default: {
            ':after': {
                content: " "    // There is a an empty space here so that the pseudo element renders
            }
        }
    });
    

    This is needed to do some styling things where content is not necessary for the pseudo element. A change that would fix this problem is simply:

        assert(val.length >= 1, 'string value cannot be blank');
    

    instead of the isBlank call. This still prevents empty strings, but allows deliberately white space strings for CSS properties.

    opened by jchristman 2
  • context would be nice to take in an entry point file to be require'd

    context would be nice to take in an entry point file to be require'd

    In react-inline it was possible to -t, --context <name=path> Add context item (require'd from path) as name and it was possible to define complex data structures in the required file etc but it appears this functionality has been removed here. With context defined in the .babelrc it's very inflexible. The use case I'm talking about is defining colors and using darken or lighten from color.js to define some more colors and then to use this in the style sheet definitions.

    opened by cly 2
  • add failing test case for nested selector

    add failing test case for nested selector

    hello

    I open a PR to discuss the support of nested selector (issue #24) I propose to handle global nesting using a parent prop in the specification object that is generated

    Another way to support that is to it like in sass, using & char

    cssInJS({
      foo: {
        '& .bar': {
          color: 'red'
        },
        '.bar &': {
          color: 'green'
        }
      }
    })   
    

    should generate

    .foo .bar {
      color: red;
    }
    .bar .foo {
      color: green;
    }
    

    what do you prefer ? and given i'm pretty new to babel-plugin, is there a simpler solution ?

    opened by lionelB 1
  • About more universal Nested Rules

    About more universal Nested Rules

    Currently babel-plugin-css-in-js support some nested rules using global selectors $, but they are very limited. I'm considering implementing nested rules for a universal case used in css pre-processes such as less and stylus. ( see the example below )

    Component:

    <div className={ st.box }>
      <div className={ st.hiddenBtn }/>
    </div>
    

    css-in-js

    const st = cssInJS({
      box: {
        color: 'red',
      },
    
      hiddenBtn: {
        opacity: 0
      },
    
      // I want to follow Nested Rules
      'box:hover': {
        '.hiddenBtn': {
          opacity: 1,
        }
      }
    })
    

    babel:

    const st = {
      box: 'dir_filename_js-styles-box',
      hiddenBtn: 'dir_filename_js-styles-hiddenBtn'
    }
    

    css

    .dir_filename_js-styles-box {
      color: red;
    }
    .dir_filename_js-styles-hiddenBtn {
      opacity: 0;
    }
    .dir_filename_js-styles-box:hover .dir_filename_js-styles-hiddenBtn {
      opacity: 1;
    }
    

    screen shot 2017-03-27 at 8 22 18 pm [Image1]

    In the First box in Image1 .box .hiddenBtn selector works well. But in the second box, .box .hiddenBtn selector will select all .hiddenBtn in the box. it might be a bug. (Because developers always can write .box .hiddenBtn selector instead of .box > .hiddenBtn selector, I don't mention about .box > .hiddenBtn selector here )

    So I like the globally unique (randomized) className this plugin creates. Ever since I use this plugin, no matter how big the application was, there was no bug affected by the unintentional css rule. In order to keep this benefit, in nested rules, both box and hiddenBtn must be uniqued.

    The global selector concept is great for theme, but I want to implement nested rules with a more universal concept that is used by other pre-processors that operate independently of the global selector nested rules.

    Could I make some PR?

    opened by b6pzeusbc54tvhw5jgpyw8pwz2x6gs 3
  • nested selector

    nested selector

    Hello,

    I wonder if there is a way to do something like

    cssInJS({
      Title: {
         color: "red"
      },
      '$.my-webfont Title: {
          font-family: webfont'
       }
    })
    

    When dealing with async font loading, a common technique is to use a font-observer like https://github.com/bramstein/fontfaceobserver and decorate the body tag with specific classes once font are available.

    opened by lionelB 4
  • feature request: support template literal

    feature request: support template literal

    I love inline-css, but I don't like the mental gymnastics I need to do to convert css into a js object.

    Could we add template literal support to allow us to write more vanilla css?

    for example we could convert this:

    const styles =  cssInJs({
      myButton: {
        border: 'solid 1px #ccc',
        backgroundColor: 'lightgray',
    
        ':hover': {
          borderColor: '#ddd',
    
          ':active': {
            borderColor: '#eee'
          }
        },
    
        '[disabled]': {
          opacity: .5,
        }
      },
    
      '@media only screen and (max-width: 480px)': {
        myButton: {
          borderWidth: 0
        }
      }
    })
    

    to

    const styles =  cssInJs(`
      .myButton {
        border: solid 1px #ccc
        background-color: lightgray
    
        &:hover {
          border-color: #ddd
    
          &:active {
            border-color: #eee
          }
        }
    
        &[disabled] {
          opacity: .5
        }
    
        @media only screen and (max-width: 480px) {
          border-width: 0
        }
      }
    `)
    

    the output would be the same

    const styles = {
      myButton: 'example_js_styles_button'
    }
    
    opened by Pyrolistical 4
  • Should not split media query blocks

    Should not split media query blocks

    Single media query blocks in the source JS are currently split up into multiple blocks, one per selector, in the output CSS. This creates larger files and also potentially slows down browser rendering.

    var x = cssInJS({
      foo: { margin: 10 },
      bar: { border: '2px solid black' },
      baz: { padding: '0 20px' },
      '@media only screen and (min-width: 500px)': {
        foo: { margin: 5 },
        bar: { border: '1px solid black' },
        baz: { padding: '0 10px' },
      }
    });
    

    becomes:

    {
      .foo { margin: 10px }
      @media only screen and (min-width: 500px) {
        .foo { margin: 5px }
      }
      .bar { border: 2px solid black }
      @media only screen and (min-width: 500px) {
        .bar { border: 1px solid black }
      }
      .baz { padding: 0 20px }
      @media only screen and (min-width: 500px) {
        .baz { padding: 0 10px }
      }
    }
    

    instead of:

    {
      .foo { margin: 10px }
      .bar { border: 2px solid black }
      .baz { padding: 0 20px }
      @media only screen and (min-width: 500px) {
        .foo { margin: 5px }
        .bar { border: 1px solid black }
        .baz { padding: 0 10px }
      }
    }
    
    opened by steadicat 0
  • CSS specificity

    CSS specificity

    All generated classes have the same specificity, but that complicates extending generic styles with custom styles for a specific theme.

    Example:

    // Button.jsx
    
    import React from 'react';
    import classNames from 'classnames';
    
    const Button = ({ className, children }) => (<button className={classNames(styles.button, className)}>{children}</button>);
    
    const styles = cssInJS({
      button: {
        color: 'blue';
      }
    });
    
    export default Button;
    
    // CustomButton.jsx
    
    import React from 'react';
    import Button from 'Button';
    
    const CustomButton = () => (<Button className={styles.customButton}>Click me!</Button>);
    
    const styles = cssInJS({
      customButton: {
        color: 'green'
      }
    });
    
    export default CustomButton;
    

    When I render CustomButton, the color: 'blue' still takes precedence over color: 'green', but I want my green theming to override the default styling. Is there a mechanism to do that without resorting to specificity hacks?

    opened by rybon 17
Owner
Martin Andert
Martin Andert
A Unique Food order landing page web application called 'HOMELY' where you can select available meals and add them to cart then order them.

End Result Click the link : https://foodapp-by-eniola.netlify.com Getting Started with Create React App This project was bootstrapped with Create Reac

Eniola Odunmbaku 26 Dec 31, 2022
PostCSS plugin to render WordPress global styles from a theme.json file

postcss-wp-global-styles PostCSS plugin to render WordPress global styles from a theme.json file. As of now it only supports preset styles. Usage @wp-

Luehrsen // Heinrich 10 Aug 5, 2022
Install the latest artifacts automatically and launch your server in a production ready mode with accessible convars.

Setup Edit the first three lines of the index.ts file to set your custom folder layout, follow the folder structure below for a example. const server_

null 2 Feb 4, 2022
700+ Pure CSS, SVG & Figma UI Icons Available in SVG Sprite, styled-components, NPM & API

700+ Pure CSS, SVG & Figma UI Icons Available in SVG Sprite, styled-components, NPM & API

Astrit Malsija 8.9k Jan 2, 2023
Automatically convert those LESS file which is not using less function to CSS.

less-2-css Automatically convert those .less file which is not using less function to .css. Why Less is a powerful CSS pre-processor, but it also very

UmiJS 14 May 24, 2022
A set of small, responsive CSS modules that you can use in every web project.

Pure A set of small, responsive CSS modules that you can use in every web project. http://purecss.io/ This project is looking for maintainers to suppo

Pure CSS 22.7k Jan 3, 2023
A browserify plugin to load CSS Modules

css-modulesify A browserify plugin to load CSS Modules. Please note that this is still highly experimental. Why CSS Modules? Normally you need to use

null 407 Aug 15, 2022
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress ?? Looking for v5? The master branch is un

styled-components 38k Dec 31, 2022
Easily create css variables without the need for a css file!

Tailwind CSS Variables This plugin allows you to configure CSS variables in the tailwind.config.js Similar to the tailwindcss configurations you are u

Mert Aşan 111 Dec 22, 2022
Easily create and maintain style guides using CSS comments

mdcss lets you easily create and maintain style guides with CSS comments using Markdown. /*--- title: Buttons section: Base CSS --- Button styles c

Jonathan Neal 679 Oct 4, 2022
Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation

Aphrodite Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation. Support for colocating y

Khan Academy 5.3k Jan 1, 2023
Dropbox’s (S)CSS authoring style guide

Dropbox (S)CSS Style Guide “Every line of code should appear to be written by a single person, no matter the number of contributors.” —@mdo General Do

Dropbox 890 Jan 4, 2023
NES-style CSS Framework | ファミコン風CSSフレームワーク

日本語 / 简体中文 / Español / Português / Русский / Français NES.css is a NES-style(8bit-like) CSS Framework. Installation Styles NES.css is available via ei

null 19.2k Jan 5, 2023
styled component for react & style-loader/usable

react-styled ES7 decorator for dynamic stylesheet usage w/ webpack install $ npm install bloody-react-styled --save-dev require import styled from "bl

Matthias Le Brun 37 Sep 26, 2022
CSSHell - Collection of common CSS mistakes, and how to fix them

CSS Hell - To Hell with bad CSS! Collection of common CSS mistakes, and how to f

Stefánia Péter 181 Nov 4, 2022
Reseter.css - A Futuristic CSS Reset / CSS Normalizer

Reseter.css A CSS Reset/Normalizer Reseter.css is an awesome CSS reset for a website. It is a great tool for any web designer. Reseter.css resets all

Krish Dev DB 1.1k Jan 2, 2023
Automatically generate a style guide from your stylesheets.

StyleDocco StyleDocco generates documentation and style guide documents from your stylesheets. Stylesheet comments will be parsed through Markdown and

Jacob Rask 1.1k Sep 24, 2022
Fluent UI web represents a collection of utilities, React components, and web components for building web applications.

Fluent UI Web ?? ?? ?? Version 8 of @fluentui/react is now available on npm! ?? ?? ?? See the release notes for more info, and please file an issue if

Microsoft 14.5k Jan 4, 2023
JSS is an authoring tool for CSS which uses JavaScript as a host language.

JSS A lib for generating Style Sheets with JavaScript. For documentation see our docs. Backers Support us with a monthly donation and help us continue

JSS 6.9k Dec 31, 2022