Stillwind sorts utilities, and a document formatter controls layout and whitespace. How you combine them depends on the formatter:
| Formatter | Setup |
|---|---|
| Prettier | The Prettier plugin sorts during formatting |
| Oxfmt or another | Run stillwind fmt first, then run the formatter |
| Any, in the editor | Code Actions sort on save |
All of them read the sort field of
stillwind.config.ts and use the same order. Sorting runs whatever the severity of
prefer-sorted-utilities is. To stop all
sorting, set sort: false.
Create stillwind.config.ts with Getting started first.
Prettier
prettier-plugin-stillwind sorts Stillwind inputs before Prettier formats a
document. Install it with Prettier 3.7 or a newer 3.x version:
vp i -D prettier prettier-plugin-stillwindnpm install -D prettier prettier-plugin-stillwindpnpm add -D prettier prettier-plugin-stillwindyarn add -D prettier prettier-plugin-stillwindbun add --dev prettier prettier-plugin-stillwindexport default {
plugins: ["prettier-plugin-stillwind"],
};JavaScript, JSX, TypeScript, TSX, CSS, and Vue work without other plugins. For Svelte and Astro, install their Prettier plugins, and load them before the Stillwind plugin:
export default {
plugins: ["prettier-plugin-svelte", "prettier-plugin-astro", "prettier-plugin-stillwind"],
};Configuration
The plugin uses the nearest stillwind.config.* above each file. The
stillwindConfig Prettier option selects another configuration, with a path
relative to the working directory. The plugin reloads the configuration for each
formatting request.
A file with no configuration, or outside the files of its project, keeps ordinary
Prettier formatting. An invalid explicit configuration fails the formatting
request, and so does incomplete or conflicting analysis.
What the plugin changes
The plugin only sorts. To replace utilities with their canonical spellings, run
stillwind lint --fix.
prettier-ignoreprotects the following syntax node from sorting.- Range formatting protects the source outside the range.
- Suppression comments control lint findings and fixes, and they do not stop sorting.
- Sorting keeps the spelling of each token.
Other formatters
Run stillwind fmt first. It sorts utilities and keeps the source layout, and the
formatter then controls whitespace:
vp exec stillwind fmt
vp exec oxfmtnpx stillwind fmt
npx oxfmtpnpm exec stillwind fmt
pnpm exec oxfmtyarn stillwind fmt
yarn oxfmtbunx stillwind fmt
bunx oxfmtIn CI, check both without saving files:
vp exec stillwind fmt --check
vp exec oxfmt --checknpx stillwind fmt --check
npx oxfmt --checkpnpm exec stillwind fmt --check
pnpm exec oxfmt --checkyarn stillwind fmt --check
yarn oxfmt --checkbunx stillwind fmt --check
bunx oxfmt --checkSee the CLI reference for the options of fmt.