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-recess

v0.0.6

Published

Use SCSS like syntax to write React inline styles.

Downloads

49

Readme

Recess

Use SCSS-like syntax to write React inline styles.

What does it do / how does it work?

Recess makes inline styling in React easier to work with. It allows you to use nested css selectors to apply inline styles to your React components, as well as supporting the :hover and :active pseudo selectors. It will feel very natural to you if you've used SCSS or SASS before and are looking to adopt React-esque inline styles.

Example:

// Styles
import recess from 'recess'

render () {
  const styles = {
    'div': {
      padding: '15px',
      
      '.inner': {
        width: '150px',
        height: '150px',
        
        '.invisible': {
          display: 'none'
        }
      },
      
      '.inner.blue': {
        background: '#00f',
        
        ':hover': {
          background: '#00e',
          
          '.invisible': {
            display: 'block'
          }
        },
        
        ':active': {
          background: '#00d'
        }
      }
    }
  }
  
  // React component
  const component = (
    <div>
      <div className='inner red'>
        <div className='invisible'>Invisible</div>
      </div>
      
      <div className='inner blue'>
        <div className='invisible'>Hovered!</div>
      </div>
    </div>
  );
  
  return recess(component, styles, this)
}

The result of this render will look like this:
recess-example

Why, why have you done this?

One of the key features of SASS/SCSS is the ability to nest your styles like so:

  .outerClass {
    background: #f00;
    
    .innerClass {
      text-align: left;
    }
  }

As well as improved specificity, this allows you have at least some idea of where these styles reside in the DOM while you're writing them - a huge improvement over traditional flat css structure. While SCSS has a number of great benefits, writing CSS in seperate files with it's own compilation pipeline has started to feel outdated and clunky (especially in the context of what the .jsx extension has done for HTML)

The alternative of course is using React inline styles. However, there are still numerous problems with this approach, including:

  • No support for pseudo selectors, most glaringly :hover and :active
  • No support for keyframes or @media
  • No builtin support for an equivalent concept of multiple classes, or selector specificity
  • Your .jsx HTML ends up bloated with style={{}} properties which rapidly becomes very difficult to read and maintain

Recess does (and will in future) attempt to address some of these issues with the goal of making styling in React easy, readable and maintanable. Another development philosophy of recess is that using this library should contribute as little boiler plate footprint to your application as possible.

Installation

npm install react-recess

Usage

As stated previously, if you've used SASS before recess should feel very familiar. It tries to stay as close as possible to the way that native CSS behaves, including element and class selectors.

import recess from 'react-recess' // recess is the default function export

render () { // The render function on your component
  const style = {
    'div': { // This will match the outer div tag
      
      '.inner': { // This will match a className prop on any element
        color: '#fff'
      }
    }
  }
  
  // As you can 
  const component = (
    <div>
      <div className='inner' style={{ color: '#000' }}>Inline styles take highest specificity, and will override matching styles</div>
    </div>
  );
  
  return recess(component, style, this); // This is where recess does it's magic - make sure to remember the component context "this" as the last argument.
}

Style API

Note that in the API a StyleTree object as an argument simply refers to another object of nested styles.

  • :hover - StyleTree - When the user hovers over this element, any additional styles (including children) inside this object will be applied. This function uses the onMouseEnter and onMouseLeave functions internally, and will transparently wrap any inline functions you pass.
const style = {
  'div': {
    ':hover': {
      color: 'red'
    }
  }
}
  • :active - StyleTree - While the user clicks and holds the mouse down, any additional styles (including children) inside this object will be applied. This function uses the onMouseDown and onMouseUp functions internally, and will transparently wrap any inline functions you pass.
const style = {
  'div': {
    ':active': {
      color: 'red',
      
      '.message': { // Will only be visible when parent is active
        visiblity: 'visible'
      }
    }
  }
}
  • @includes - Array[StyleTree] - Pass an array of style objects to automatically merge additional styles (including children) into the styles applied to this matched element.
const confirmButton = {
  background: 'green',
  color: 'white',
  
  ':hover': {
    background: 'black'
  }
}

const style = {
  'div': {
    fontSize: '12px',
    '@includes': [confirmButton] // This will inherit all styles from confirmButton, including the :hover and any child selectors
  }
}

Contributing

As long as you're familiar with GitHub flow, feel free to open a pull request if you have some additional functionality you'd like to see in recess.

Recess is under active development

Recess is currently developed and maintained by @nicbarker, and is used in production on Kakushin.