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

tailwind-style-sheets

v0.0.1

Published

A Turbopack loader and Next.js plugin for `.twss` files — co-locate your Tailwind class maps alongside components.

Downloads

99

Readme

tailwind-style-sheets

A Turbopack loader and Next.js plugin for .twss files — co-locate your Tailwind class maps alongside components.

What it does

.twss files use a CSS-like syntax to define named Tailwind class groups. Each class can be written on its own line — this is the preferred style as it keeps diffs clean and classes easy to scan:

/* Button.styles.twss */
.button {
  @apply
  cursor-pointer
  px-4
  py-2
  rounded-full
  text-sm
  font-medium
  transition-all
  active:scale-95
}

.button--primary {
  @apply
  bg-blue-600
  text-white
  hover:bg-blue-700
}

.button--ghost {
  @apply
  bg-transparent
  text-blue-600
  hover:bg-blue-50
}

Inline is also valid:

.button {
  @apply cursor-pointer px-4 py-2 rounded-full text-sm font-medium transition-all active:scale-95
}

Importing a .twss file gives you a plain object:

import styles from "./Button.styles.twss";
// styles.button          → "cursor-pointer px-4 py-2 rounded-full text-sm font-medium transition-all active:scale-95"
// styles["button--primary"] → "bg-blue-600 text-white hover:bg-blue-700"
// styles["button--ghost"]   → "bg-transparent text-blue-600 hover:bg-blue-50"

Pair it with @michalshelenberg/modcn to compose BEM classes ergonomically:

import { modcn } from "@michalshelenberg/modcn";
import styles from "./Button.styles.twss";

const cn = modcn(styles);

export function Button({ variant = "primary", className, children, ...props }) {
  return (
    <button {...props} className={cn("button", `button--${variant}`, className)}>
      {children}
    </button>
  );
}

Installation

npx tailwind-style-sheets init

This scaffolds all required files and installs the package.

Manual installation

npm install tailwind-style-sheets

next.config.ts

import type { NextConfig } from "next";
import path from "path";
import { withTwssPlugin } from "tailwind-style-sheets";

const nextConfig: NextConfig = {};

export default withTwssPlugin(nextConfig, {
  globalsCSS: path.resolve(__dirname, "src/app/globals.css"),
  watchDir: path.resolve(__dirname, "src"),
});

withTwssPlugin options:

| Option | Type | Description | | ------------ | -------- | ------------------------------------------------------------------------------------ | | globalsCSS | string | Absolute path to your global CSS file. Touched on .twss changes to trigger HMR. | | watchDir | string | Directory to watch recursively for .twss file changes. Only active in development. |

Both options are optional. Omitting them disables the HMR watcher (the loader still works).

TypeScript

Add a declaration file so TypeScript knows .twss imports return Record<string, string>:

// global.d.ts
declare module "*.twss" {
  const styles: Record<string, string>;
  export default styles;
}

VSCode

Install the Tailwind CSS IntelliSense extension to get Tailwind class autocomplete and hover previews inside .twss files.

Add to .vscode/settings.json to get CSS syntax highlighting and silence the @apply warning:

{
  "css.lint.unknownAtRules": "ignore",
  "files.associations": {
    "*.twss": "css"
  }
}

How it works

  1. Loader (loader.ts) — Turbopack passes the raw .twss file content through the loader. A regex extracts each .className { @apply ... } block and converts it to export default { className: "class1 class2 ..." }.

  2. HMR watcher (plugin.ts) — In development, fs.watch monitors watchDir for .twss changes. When a change is detected, it touches globalsCSS, which causes Next.js to re-run Tailwind's class scan and hot-reload styles.