prettier-plugin-tailwind-variants weekly downloads statistics
By tianenpang · npm · Prettier plugins
A Prettier plugin for Tailwind Variants that formats class arrays while preserving structure, then sorts them with prettier-plugin-tailwindcss
prettier-plugin-tailwind-variants has 8 recorded weekly downloads on npm, a decrease of 50.0% over the past 30 days, ranking #2089 of 2,322 tracked listings.
About prettier-plugin-tailwind-variants
prettier-plugin-tailwind-variants
<img src="./.github/banner.jpg" alt="prettier-plugin-tailwind-variants" />A Prettier plugin for Tailwind Variants. Formats tv() class arrays while preserving structure, then sorts with prettier-plugin-tailwindcss.
Installation
pnpm add -D prettier prettier-plugin-tailwindcss@^0.8.0 prettier-plugin-tailwind-variants
// prettier.config.js
import * as tailwindcss from 'prettier-plugin-tailwindcss';
import tailwindVariants from 'prettier-plugin-tailwind-variants';
/** @type {import('prettier').Config} */
export default {
plugins: [tailwindVariants(tailwindcss)],
tailwindFunctions: ['tv'],
tvFunctions: ['tv']
};
Must be composed with prettier-plugin-tailwindcss as above.
Options
| Option | Default | Description |
|---|---|---|
tvFunctions | ['tv'] | Callee names to format. Keep tailwindFunctions in sync for string sorting. |
tvUnwrapSingleClassArrays | true | Unwrap nested single-class arrays into the parent sort pool. Ignored when grouping or flattening. |
tvGroupByModifiers | false | Split tokens into one string per modifier group (base, hover, dark, …). |
tvModifierGroupOrder | built-in | Group id order when grouping is on. Ignored when grouping is off. |
tvFlattenToString | false | Flatten arrays / nests into a single class string. Ignored for final shape when grouping is on. |
tvRemoveEmptyClasses | true | Remove empty / whitespace-only class strings and empty arrays. |
tvGroupByBreakpoints | false | When grouping, put each breakpoint (sm, md, …) in its own group. Ignored when grouping is off. |
Shape priority: tvGroupByModifiers → else tvFlattenToString → else preserve structure (+ unwrap).
// tvGroupByModifiers: true
base: ['dark:bg-black', 'px-4', 'hover:bg-red-500', 'py-2'];
// →
base: ['px-4 py-2', 'hover:bg-red-500', 'dark:bg-black'];
// tvFlattenToString: true
base: ['text-white', ['py-2', 'px-4'], 'rounded-lg'];
// →
base: 'rounded-lg px-4 py-2 text-white';
Formatting
// Before
tv({
base: ['text-white', ['py-2', 'px-4'], 'rounded-lg']
});
// After (default structure mode)
tv({
base: ['rounded-lg', ['px-4', 'py-2'], 'text-white']
});
Covers base, slots, variants, compoundVariants / compoundSlots (class / className). JS/TS and <script> regions (Vue, Svelte, Astro, HTML, …); CSS is left alone. Framework parsers need their own Prettier plugins.
Editor IntelliSense
Prefer key-scoped classRegex over classFunctions: ["tv"] so conditions and defaultVariants are skipped. Copy from .vscode/settings.json and enable "editor.quickSuggestions": { "strings": "on" }.
{
"tailwindCSS.experimental.classRegex": [
["\\b(?:base|class|className)\\s*:\\s*['\"`]([^'\"`]*)['\"`]"],
[
"\\b(?:base|class|className)\\s*:\\s*(\\[(?:[^\\[\\]]|\\[(?:[^\\[\\]]|\\[(?:[^\\[\\]]|\\[[^\\[\\]]*\\])*\\])*\\])*\\])",
"['\"`]([^'\"`]*)['\"`]"
],
["\\b(?:class|className)\\s*:\\s*(\\{(?:[^{}]|\\{[^{}]*\\})*\\})", "['\"`]([^'\"`]*)['\"`]"],
["\\bslots\\s*:\\s*(\\{(?:[^{}]|\\{[^{}]*\\})*\\})", "['\"`]([^'\"`]*)['\"`]"],
[
"\\bvariants\\s*:\\s*(\\{(?:[^{}]|\\{(?:[^{}]|\\{(?:[^{}]|\\{[^{}]*\\})*\\})*\\})*\\})",
"['\"`]([^'\"`]*)['\"`]"
]
]
}
Limitations
- Static strings and literal arrays only
- Dynamic values skip that array
- Peers:
prettier@^3.0.0,prettier-plugin-tailwindcss@^0.8.0
Community
Contributing · Code of Conduct · Security · Support
License
Description from the npm listing.
- prettier
- prettier-plugin
- tailwind
- tailwindcss
- tailwind-variants
- formatting
- class-sorting
- variants
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (544)Similar npm Prettier plugins plugins
All 20 prettier-plugin-tailwind-variants alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/prettier-plugin-tailwind-variants. First seen Oct 16, 2026; last successful collection Oct 20, 2026. See the methodology.