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

lightningcss-tailwindcss

v2.1.0

Published

Lightning CSS AST utilities for analyzing Tailwind CSS syntax

Readme

lightningcss-tailwindcss

Lightning CSS AST utilities for analyzing Tailwind CSS syntax.

Overview

This package provides a Tailwind-oriented analysis layer on top of Lightning CSS AST.

It extracts:

  • @apply utility candidates
  • theme(...) calls
  • Tailwind import directives
  • utility selectors declared in authored stylesheets
  • basic Tailwind version hints from parsed syntax
  • parser warnings emitted while Lightning CSS recovers invalid or custom syntax

This package is useful when your tooling already depends on Lightning CSS AST and you want to inspect Tailwind-related syntax without switching to PostCSS.

Installation

pnpm add -D lightningcss-tailwindcss

When To Use This Package

Use lightningcss-tailwindcss when:

  • your pipeline already uses lightningcss
  • you want a fast Rust-backed parser with JS visitor access
  • you are comfortable with recovered/normalized AST output

Use postcss-tailwindcss instead when:

  • you need more permissive authored-source parsing
  • you want direct PostCSS node references
  • you need project-aware Tailwind runtime/config resolution

API

  • parseTailwindCss(input)
  • detectTailwindVersion(input)
  • collectApplyCandidates(input)
  • collectThemeCalls(input)
  • collectImportDirectives(input)
  • collectUtilitySelectors(input)
  • analyzeTailwindCss(input)

Example

import { analyzeTailwindCss } from 'lightningcss-tailwindcss'

const css = `
@import "tailwindcss" source(none) prefix(tw);

.button {
  @apply flex hover:bg-red-500;
  color: theme(colors.gray.900 / 75%);
}
`

const result = analyzeTailwindCss(css)

console.log(result.version)
console.log(result.applyCandidates.map(item => item.candidate))
console.log(result.warnings)

Return Shape

analyzeTailwindCss() returns:

interface TailwindAnalysis {
  version: 3 | 4 | 'unknown'
  applyCandidates: UtilityCandidate[]
  themeCalls: ThemeCall[]
  importDirectives: TailwindImportDirective[]
  utilitySelectors: UtilitySelector[]
  warnings: LightningWarning[]
}

Unlike the PostCSS version, this package returns Lightning CSS AST fragments and loc data rather than PostCSS nodes.

Parsing Behavior

This package relies on Lightning CSS transform() with errorRecovery: true.

That means:

  • unsupported Tailwind syntax may still be preserved in recovered form
  • parser warnings are expected for some Tailwind-specific constructs
  • v4 @import "tailwindcss" source(...) prefix(...) is analyzable even if Lightning CSS treats parts of it as recovered tokens

Important Differences From postcss-tailwindcss

  • No Tailwind runtime resolution helpers
  • No PostCSS node references
  • More normalized AST output
  • Better fit for tools that already consume Lightning CSS visitors

If you need to inspect the consuming project's installed Tailwind runtime or config file, use postcss-tailwindcss.

Project links

  • Documentation: https://repoctl.icebreaker.top
  • Repository: https://github.com/sonofmagic/repoctl/tree/main/packages/lightningcss-tailwindcss
  • Issues: https://github.com/sonofmagic/repoctl/issues