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

@glowingblue-dev/shadow-css

v1.1.0

Published

Allow injecting CSS rules from a specified attribute into the shadow DOM of elements.

Readme

npm version code style: prettier

@glowingblue-dev/shadow-css

Injects custom CSS into open shadow roots via HTML attributes with optional runtime watching for attribute changes or newly added nodes.

Features

  • Add inline CSS or external .css files into open shadow roots
  • Works with one or multiple attributes
  • Optional live watching via MutationObserver: React to attribute changes and dynamically added nodes
  • Zero dependencies, tiny footprint

Install

npm install @glowingblue-dev/shadow-css

or

yarn add @glowingblue-dev/shadow-css

Usage

Assuming an unstyleable third party WebComponent with an open shadow DOM like:

<custom-element>[#shadowDOM]<div class="classname"></div>[/#shadowDOM]</custom-element>

Inline styles

<custom-element data-css=".classname { color: red; }"></custom-element>
import $shadowCSS from "@glowingblue-dev/shadow-css";

$shadowCSS("data-css");

External stylesheet

<custom-element data-css="/path/to/styles.css"></custom-element>
$shadowCSS("data-css", { watch: true });

Multiple attributes

<custom-element
  data-theme="/themes/dark.css"
  data-css=".classname { color: red; }"
></custom-element>
$shadowCSS(["data-theme", "data-css"], { watch: true });

API

$shadowCSS(attrs?: string | string[], options?: { watch?: boolean }, target?: Node): MutationObserver
  • attrs — one or more attribute names (default: "data-css").
  • options.watch — if true, sets up a MutationObserver to update when the attribute value changes or when new elements with the attribute are added.
  • options.target - The target node to to look for attributes and optionally observe, defaults to the global document.

Always returns a MutationObserver instance, if watch: true it is already activated and observing the DOM and can be disabled by calling .disconnect() at any later point. If watch: false (default) you can activate it at a point of your choosing by calling .observe(<target>, <options>). The default options are attached to the returned MutationObserver instance for convenience.

Scoping tips

When using a shared stylesheet across multiple components, scope your rules with :host(...):

:host(custom-element) .selector {
  transform: rotate(180deg);
}

:host(custom-element) {
  & .selector {
    ...;
  }
  &:hover .selector {
    ...;
  }
}

Limitations

  • Only works with open shadow DOMs. Closed roots cannot be styled this way.
  • Runs in browsers (relies on document).

License

MIT © Glowing Blue AG

Credits

Originally authored by exside