prettier-plugin-unocss weekly downloads statistics
By hexlabelposition · npm · Prettier plugins
Unofficial Prettier plugin that sorts UnoCSS utilities using your own uno.config, in the same order as the official ESLint rule.
prettier-plugin-unocss has 31 recorded weekly downloads on npm, a change of -22.5% over the past 7 days, ranking #2896 of 3,247 tracked listings.
About prettier-plugin-unocss
prettier-plugin-unocss
A Prettier plugin that sorts UnoCSS utilities, using your own uno.config. Custom rules, shortcuts and presets are sorted correctly, in the same order as the UnoCSS ESLint rule.
- <div className="shadow md:p-8 p-4 my-custom rounded-lg bg-white flex">
+ <div className="my-custom flex rounded-lg bg-white p-4 shadow md:p-8">
Think prettier-plugin-tailwindcss, but for UnoCSS.
[!NOTE] Unofficial, with the official order. This is a community plugin, not made or endorsed by the UnoCSS team. The order itself comes from UnoCSS: classes are sorted by
sortRulesfrom@unocss/core, the same function the UnoCSS ESLint rule uses.
| Section | What's inside |
|---|---|
| Why | What the plugin is for |
| Installation | Install and enable it |
| What gets sorted | Languages, attributes and functions |
| How classes are ordered | The order, duplicates, line breaks |
| Using with other Prettier plugins | Plugin order, Svelte, Astro, import sorters |
| Options | unoConfig, unoAttributes, unoFunctions, unoVariables |
| Limitations | What isn't sorted or needs care |
| Performance | Cost of the first and every next file |
| Development | Scripts and tests |
| Credits | Where the code comes from |
| License | MIT |
Why
UnoCSS already sorts classes with the ESLint rule @unocss/order. This plugin brings the same order to Prettier, for projects that format with Prettier and want classes sorted on save, without running ESLint for it.
Installation
Requires Node.js 22.18 or later and Prettier 3.
pnpm add -D prettier prettier-plugin-unocss
# or
npm install -D prettier prettier-plugin-unocss
// prettier.config.js
/**
* @see https://prettier.io/docs/configuration
* @type {import("prettier").Config}
*/
const config = {
plugins: ['prettier-plugin-unocss'],
}
export default config
That's it. The plugin finds uno.config.* (or unocss.config.*) next to each file or in a parent directory, so monorepos with several configs work. A file without a config is left untouched. If the config fails to load, Prettier reports the error with the config path, instead of silently not sorting.
In an editor, the config is loaded again when it changes, so there is no need to restart Prettier.
What gets sorted
| Where | What |
|---|---|
| JS / TS / JSX / TSX | class and className, clsx / cn / cx / classnames / tv / cva calls, class variables (const clsButton = '…') |
| Vue | class, :class (strings, arrays, objects), attributify (<div p-4 flex>) |
| HTML | class |
| Svelte | class="…", class={…}; class:name directives are left alone |
| Astro | class, class:list |
<script> blocks and the Astro frontmatter are sorted like any JS/TS file.
Inside class functions and attributes, the plugin also follows conditionals (on ? 'a b' : 'c'), && / || / ??, arrays, object values, template literals, and tagged templates whose tag is in unoFunctions (add tw there for tw`…` ). Object keys are classes in clsx-like functions (clsx({ 'p-4 flex': on })), but never in tv / cva, where they are names.
Attributify utilities are sorted only when presetAttributify is in your config.
How classes are ordered
- Classes UnoCSS doesn't know come first, in their original order.
- Then utilities, in the order of the rules that match them in your config.
- Utilities with variants (
hover:,md:) come after the ones without; more variants, further back. - Variant groups
hover:(a b)are sorted inside and stay grouped.
Icons from presetIcons count as unknown classes and go first, as with the ESLint rule: icon collections are not loaded for sorting.
Like eslint --fix with the UnoCSS rule, the plugin keeps duplicate classes (p-4 flex p-4 → flex p-4 p-4) and puts a class list split over several lines on one line.…
Description from the npm listing.
- class-sorting
- css
- formatter
- prettier
- prettier-plugin
- unocss
- unocss-plugin
- typescript
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 (128)Similar npm Prettier plugins plugins
All 20 prettier-plugin-unocss 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-unocss. First seen Nov 26, 2026; last successful collection Dec 6, 2026. See the methodology.