npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-css-in-js-component

v1.0.0

Published

A CSS-in-JS React component helper

Readme

react-css-in-js-component

A CSS-in-JS React component helper

NPM JavaScript Style Guide

Install

npm install --save react-css-in-js-component

What is this for

This helper can be used with multiple CSS-in-JS libraries, specialy the ones that don't use a component-oriented strategy (those libraries enhance the component primitives instead of parsing and applying class names to elements).

Usage

You must import the default module of react-css-in-js-component and call it as a function to pass configure your library into it. Consider doing it on your App container, since it gets place before your app is bootstrapped.

import React from 'react'
import { StyleSheet, css } from 'css-in-js-library' // See supported libraries below
import CSSComponentConfig from 'react-css-in-js-component'

CSSComponentConfig({
  StyleSheet,
  css,
  shouldFlatStyles: true,
})

export default class App extends Component {
  render () {
    return <MyComponent />
  }
}

Then, extend your components using PureComponent or Component from react-css-in-js-component instead of React, that way you can pass a static function called styles and use this.css() method to apply it to your elements.

import React from 'react'
import { Component } from 'react-css-in-js-component'

export default class MyComponent extends Component {
  styles (props) {
    return {
      container: {
        display: 'flex',
        height: '100vh',
      },
      title: {
        fontSize: '24px',
        margin: 'auto',
      },
      titleColor: {
        color: 'tomato',
      },
    }
  }

  render () {
    return (
      <div className={this.css('px')}>
        <h1 className={this.css('title', 'titleColor')}>
          Mangia che te fa bene
        </h1>
      </div>
    )
  }
}

See [example][https://github.com/fmedinac/react-css-in-js-component/tree/master/example] folder.

Supported libraries

Each library has its own way to parse stylesheet and css, the following table help you to configure react-css-in-js-component for your preffered library.

  • ✅ Supported library
  • ❓ Not tested library (yet)
  • ❌ Not supported library (yet)

| Package | Support | Configuration Notes | |-----------------|:-------------:|-------------| | emotion | ✅ | Use css from library | | fela | ❓ | | | jss | ❓ | | | rockey | ❓ | | | styled-components | ❌ | | | aphrodite | ✅ | Use StyleSheet.create for StyleSheet configuration and css| | csx | ✅ | Use cxs for css and set shouldFlatStyles: true | | glam | ❌ | | | glamor | ✅ | Use css from library | | styletron | ❌ | | | aesthetic | ❌ | | | j2c | ❓ | |

Global styles

Optionally, you can pass globalStyles when configuring react-css-in-js-component. Notice that global styles are considered fallbacks, so if your component has a style with the same name, it will be ignored. Try creating a naming convention to prevent that.

Example:

CSSComponent({
  StyleSheet,
  css,
  globalStyles: {
    mx: {
      marginLeft: 16,
      marginRight: 16,
    }
  }
})
...
  <div className={this.css('mx')} />
...

To do

  • Write tests
  • Test more libraries
  • Make HOC based libraries work
  • Make component-oriented libraries work

Thank you

This project is based on @rafaelrinaldi and @leandroferreira efforts to make CSS-in-JS great.

License

MIT © fmedinac