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 🙏

© 2025 – Pkg Stats / Ryan Hefner

styled-atom

v2.1.1

Published

CSS in JS React library ✦

Readme

✦ Table of contents

✦ About

styled-atom is a CSS in JS React library designed for managing styles dynamically in your projects. It allows you to load styles asynchronously, and track their load status.

✦ Installation

Install the library using the following command:

npm install styled-atom

✦ StyleCore

StyleCore is the foundation of the styled-atom library. It initializes the system and ensures styles are properly loaded. Place this component at the root of your application.

Props:

  • path (required): The style import function.

    import React from "react";
    import { StyleCore } from "styled-atom";
    
    const App = () => {
      <>
        <StyleCore
          path={(name: string) => import(`../src/style/css/${name}.css`)}
        />
        <YourComponent />
      </>;
    };

✦ StyledAtom

StyledAtom is used to apply styles dynamically. It can wrap your components and render them only when all the specified styles are loaded.

Props:

  • fileNames (required): Array of CSS file names required for the component.

    import React from "react";
    import { StyledAtom } from "styled-atom";
    
    const YourComponent = () => {
      <StyledAtom fileNames={["your-style1", "your-style2"]}>
        <SomeComponent />
      </StyledAtom>;
    };
  • encap (optional): Encapsulates styles with CSS file names, supports custom classes.

    import React from "react";
    import { StyledAtom } from "styled-atom";
    
    const YourComponent = () => {
      <StyledAtom
        encap
        // or encap="custom-class"
        // another props
      >
        <SomeComponent />
      </StyledAtom>;
    };
  • fallback (optional): A React element to render while styles are loading.

    import React from "react";
    import { StyledAtom } from "styled-atom";
    
    const YourComponent = () => {
      <StyledAtom
        fallback={<div>Loading...</div>}
        // another props
      >
        <SomeComponent />
      </StyledAtom>;
    };
  • onLoad (optional): Callback triggered after styles are loaded successfully.

    import React from "react";
    import { StyledAtom } from "styled-atom";
    
    const YourComponent = () => {
      <StyledAtom
        onLoad={() => console.log("The styles are loaded")}
        // another props
      >
        <SomeComponent />
      </StyledAtom>;
    };

Also, if you just want to load the style that you will need later, you can use StyledAtom not as a wrapper.

import React from "react";
import { StyledAtom } from "styled-atom";

const YourComponent = () => {
  <>
    <StyledAtom fileNames={["your-style1"]} />
    <SomeComponent />
  </>;
};

The library ensures only one style tag is used, even if the same styles appear in multiple components.

✦ Additionally

After the styles are loaded, you will see in the browser something like this:

<head>
  <style atom="✦0" name="yourStyle1">
    .yourStyle1 {
      /* encapsulated CSS */
    }
  </style>

  <style atom="✦0" name="yourStyle2">
    .yourStyle2 {
      /* encapsulated CSS */
    }
  </style>
</head>

<body>
  <div atom-shell="✦0" class="yourStyle1 yourStyle2">
    <!-- content -->
  </div>
</body>

Library encapsulation uses style file names to wrap CSS and html content through classes.

✦ API

  • StyleCore: The component for initializing the library.
  • StyledAtom: A component for creating style tags.