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

prettier-plugin-latte-tailwindcss

v0.4.0

Published

Prettier plugin for sorting Tailwind CSS v4 classes in Latte v3 templates

Readme

prettier-plugin-latte-tailwindcss

npm version license

A Prettier plugin that sorts Tailwind CSS v4 classes in Latte v3 templates.

The official prettier-plugin-tailwindcss does not support Latte. This plugin fills that gap — it handles class, n:class, class={[...]}, and custom locations via classRegex.

Installation

npm install -D prettier-plugin-latte-tailwindcss

Peer dependencies: prettier >= 3.0.0 and @tailwindcss/node >= 4.0.0.

Minimal .prettierrc:

{
  "plugins": ["prettier-plugin-latte-tailwindcss"],
  "tailwindStylesheet": "./resources/css/app.css"
}

If you omit tailwindStylesheet, the plugin uses a default @import "tailwindcss" which gives standard Tailwind class order. Set it when you have custom utilities or theme customizations.

What gets sorted

Standard HTML attributes

class and n:class attributes are always sorted automatically.

{* Before *}
<div class="mt-4 flex text-left items-center">
<div n:class="'mt-4', 'flex', $active ? 'font-bold', 'text-sm', 'items-center'">

{* After *}
<div class="flex items-center text-left mt-4">
<div n:class="'flex', 'mt-4', $active ? 'font-bold', 'items-center', 'text-sm'">

Latte array class syntax

{* Before *}
<div class={['mt-4', 'flex', 'active' => $isActive, $dynamicClass, 'text-sm']}>

{* After *}
<div class={['flex', 'mt-4', 'active' => $isActive, $dynamicClass, 'text-sm']}>

Custom locations via classRegex

Class strings inside {embed} / {include} parameters, class => in custom tags, $class variables, and more:

{embed '~card',
  class: 'mt-4 flex items-center',
  backgroundClass: $highlighted ? 'bg-brand-primary'}

{pdImg $image product-600,
  class => 'mt-4 flex items-center'}

The plugin auto-detects classRegex patterns from your IDE configuration (.vscode/settings.json or .idea/tailwindcss.xml). See Class Regex documentation for setup and recommended patterns.

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | tailwindStylesheet | string | — | Path to CSS entry point with @import "tailwindcss" | | tailwindClassRegex | string | "" | JSON array of classRegex patterns; empty = auto-detect from IDE | | tailwindAttributes | string[] | [] | Additional HTML attributes to sort as class lists | | tailwindNclassWhitespace | string | "normalize-barriers" | How n:class whitespace is handled: preserve, normalize-barriers, normalize | | tailwindPreserveWhitespace | boolean | false | Preserve whitespace in class attributes | | tailwindPreserveDuplicates | boolean | false | Keep duplicate classes | | tailwindPropertyOrder | string | "" | Path to stylelint-order compatible config for custom CSS property ordering |

See Options documentation for detailed descriptions and examples.

n:class sorting model

The plugin uses a barrier model for n:class sorting:

  • Sortable tokens: bare identifiers (active), single-class strings ('flex')
  • Barrier tokens: conditionals ($x ? 'active'), variables ($class), multi-class strings ('btn font-bold')

Sortable tokens between barriers are reordered by Tailwind order. Barrier tokens never move. Classes within any quoted string or conditional branch are always sorted internally.

Editor setup

PhpStorm / WebStorm

  1. Settings → Languages & Frameworks → JavaScript → Prettier
  2. Set Run for files to: {**/*.{js,ts,jsx,tsx,css,scss,html,json,latte}}
  3. Optionally enable On save

VS Code

  1. Install the Prettier extension
  2. Add to settings.json:
{
  "[latte]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

Known limitations

  • Range formatting may have off-by-one behavior due to the Latte preprocessing step.
  • Cross-barrier ordering is intentionally not supported in n:class.

Support

If this plugin saves you time, consider supporting its development:

License

MIT