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

powerstyl

v1.2.0

Published

A way to style elements in vanilla JavaScript

Readme

A way to style elements in vanilla JavaScript.

Installation

npm install powerstyl

Getting Started

Powerstyl mainly exports two things: styled and updateStyle.

styled is used to create an element creator.

updateStyle is used to update the style of the element created by the creator. It should be placed where the state is updated.

If the parameters of styled do not contain functions, calling updateStyle on the created element will do nothing.

import { styled, updateStyle } from "powerstyl";
const Button = styled("button")`
  font-size: 1em;
  padding: 0.2em 0.5em;
  border-radius: 0.2em;
  color: black;
  border: none;
  cursor: pointer;
  background-color: ${(e) => (e.count % 2 ? "rgb(10 240 220)" : "rgb(150, 240, 20)")};
  &:hover {
    background-color: ${(e) => (e.count % 2 ? "rgb(10 230 200)" : "rgb(150, 230, 0)")};
  }
`;
const ButtonLg = styled(Button)`
  font-size: 1.2em;
`;
const button = ButtonLg();
button.count = 0;
button.append("Click me");
button.addEventListener("click", () => {
  button.count++;
  updateStyle(button);
});
document.body.appendChild(button);

First updated:

<head>
  <style>
    [data-ps="4606c706"] {
      font-size: 1em;
      padding: 0.2em 0.5em;
      border-radius: 0.2em;
      color: black;
      border: none;
      cursor: pointer;
      background-color: rgb(150, 240, 20);
      font-size: 1.2em;
    }
    [data-ps="4606c706"]:hover {
      background-color: rgb(150, 230, 0);
    }
  </style>
</head>
<body>
  <button data-ps="4606c706">Click me</button>
</body>

After clicked:

<head>
  <style>
    [data-ps="4606c706"] {
      font-size: 1em;
      padding: 0.2em 0.5em;
      border-radius: 0.2em;
      color: black;
      border: none;
      cursor: pointer;
      background-color: rgb(150, 240, 20);
      font-size: 1.2em;
    }
    [data-ps="4606c706"]:hover {
      background-color: rgb(150, 230, 0);
    }
    [data-ps="f99b399b"] {
      font-size: 1em;
      padding: 0.2em 0.5em;
      border-radius: 0.2em;
      color: black;
      border: none;
      cursor: pointer;
      background-color: rgb(10 240 220);
      font-size: 1.2em;
    }
    [data-ps="f99b399b"]:hover {
      background-color: rgb(10 230 200);
    }
  </style>
</head>
<body>
  <button data-ps="f99b399b">Click me</button>
</body>

API Reference

styled

Create a function to create styled elements.

styled(tag, { type, manager });

Parameters

  • tag: An element tag name, custom element constructor, or function returns a element instance.
  • options
    • type: Style application type ('global', 'scoped', 'adopted' or 'inline').
    • manager: Style manager, used to update DOM and application styles.

updateStyle

Updates the style of an element created by styled.

updateStyle(element);

Parameters

  • element: The element whose style needs to be updated which created by styled function

Style Application Types

Global

Styles applied globally.

const MyComponent = styled("div", {
  type: "global",
  globalEffect: (id, element) => {
    element.dataset.ps = id;
    return `[data-ps="${id}"]`;
  },
})`
  /* root styles */
  &:hover {
    /* hover styles */
  }
`;
MyComponent();
<head>
  <style>
    [data-ps="11201b20"] {
      /* root styles */
    }
    [data-ps="11201b20"]:hover {
      /* hover styles */
    }
  </style>
</head>
<body>
  <div data-ps="11201b20"></div>
</body>

Scoped

Styles applied within a scope.

const MyComponent = styled("div", { type: "scoped" })`
  /* root styles */
  &:hover {
    /* hover styles */
  }
`;
MyComponent();
<div>
  <style>
    @scope {
      :scope {
        /* root styles */
      }
      :scope:hover {
        /* hover styles */
      }
    }
  </style>
</div>

Adopted

Styles applied within a shadow root.

const MyComponent = styled("element-with-shadow-root", { type: "adopted" })`
  /* host styles */
  &:hover {
    /* hover styles */
  }
`;
MyComponent();
:host {
  /* host styles */
}
:host(:hover) {
  /* hover styles */
}

Inline

Styles applied directly as inline styles to the element.

const MyComponent = styled("div", { type: "inline" })`
  /* inline styles */
`;
MyComponent();
<div style="/* inline styles */"></div>