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

pretty-components

v1.0.4

Published

Prop-based styled components

Readme

🌈 Pretty Components

Prop-based styled components.

  • React components props as selectors
  • Sass nested styles
  • Use variables
  • Generate readable class names (Button, Button--is-selected, ...)

Install

// Hello.pss

Hello {
  border: 2px solid yellow;
  background: $background;

  ::isSelected {
    &:hover {
      border-color: purple;
    }
  }

  ::size {
    ::small {
      font-size: 12px;
    }

    ::big {
      font-size: 16px;
    }
  }
}

// Will generate the following
.Hello
.Hello--is-selected
.Hello--size-small
.Hello--size-big

// For a nameless component, use ":root" instead of "Hello";
// it will generate a random identifier

Pretty, pretty, pretty good

Why?

If you want to apply prop-based styles to your React components so far, you either need to:

  • write css classes, then manually map them to each state of our component props
    if prop.isSelected, add 'is-selected' css class
  • use expressions (with css-in-js) inside style literals
    ${props => props.isSelected ? 'blue' : 'red'}

Now, let's think for one second: do we have any additional logic for mapping our element to hover styles only when it'll be hovered? Of course we don't, because we already acknowledge that writing :hover makes it conditionally styled, based on our element's state.

The idea here is similar: making props part of that state, right inside our style declaration.

Link Style to its Component

import React from 'react';
import { style } from 'pretty-components';
import styles from './Hello.pss'; // only possible when using Webpack

function Hello(props) {
  return <h1 className={props.className}>{props.children}</h1>;
}

// or even simpler
// const Hello = style('h1', styles);

export default style(Hello, styles);

// later
<Hello size="big">Hello World</Hello>

Set variables

import { styleVariables } from 'pretty-components';

// This code needs to be called before any other `pretty-components`'d
// component code is called.
styleVariables({
  background: 'red', // will be available as $background in every stylesheet
  // ...
});

How to Use without Webpack

Without Webpack —at least for now, you won't be able to directly use PSS syntax. What the Webpack loader actually do is transforming PSS syntax into vanilla javascript code:

import { stylesheet } from 'pretty-components-formatter';

export default stylesheet('Hello', {
  border: '2px solid yellow',
  background: '$background',
  _isSelected: {
    '&:hover': {
      borderColor: 'purple',
    }
  },
  _size: {
    _small: {
      fontSize: 12,
    },
    _big: {
      fontSize: 16,
    }
  }
});

License

eveningkid @ MIT