CLI for organizing Tailwind CSS classes
Available via npm
yarn global add rustywind
or
npm install -g rustywind
or
Install from homebrew (mac and linux):
brew install avencera/tap/rustywind
or
Install from crates.io:
cargo install rustywind
or
cargo binstall rustywind
or
Install from a github release:
curl -LSfs https://avencera.github.io/rustywind/install.sh | sh -s -- --git avencera/rustywind
or
Download a release directly from github: github.com/avencera/rustywind/releases
or
You can use the dockerized version
docker run --rm -v $PWD:/app avencera/rustywind:latest
Run rustywind with a path to output updated file contents to the terminal:
rustywind .If you want to reorganize all classes in place, and change the files run with the --write flag
rustywind --write .Run rustywind with a path and the --dry-run to get a list of files that will be changed:
rustywind --dry-run .Run rustywind on your STDIN:
echo "" | rustywind --stdinRustyWind infers template syntax from file extensions. Override it when a file uses a different language:
rustywind --language svelte Component.htmlProvide a filename when sorting standard input so RustyWind can infer its template syntax:
cat Component.svelte | rustywind --stdin --stdin-filename Component.svelteSupported language profiles are HTML, JSX/TSX, Svelte, Astro, Django, Jinja, Twig, Liquid,
Handlebars, ERB, EJS, PHP, Blade, Lit, and Ruby. JSX and TSX program text, comments, and dynamic
attributes are preserved while directly quoted class and className attributes are sorted.
Astro frontmatter, expressions, dynamic class attributes, and class:list directives are
preserved while static quoted class attributes are sorted. Files with
unrecognized extensions use conservative legacy-compatible extraction: simple static class
attributes are sorted, while template-looking attributes remain unchanged. Because a plain .html
extension does not identify its template engine, attributes with template syntax are left unchanged
unless a profile such as --language django is selected.
Run in CI, exit with error if unsorted classes are found:
rustywind --check-formatted .Add --json to any of these modes to print a single machine-readable JSON document instead of the
human output:
rustywind --check-formatted --json .rustywind --dry-run --json .rustywind --write --json .echo "" | rustywind --stdin --jsonBare rustywind --json . behaves like --dry-run --json and never writes files. Unlike the human
dry run, dry-run JSON includes the full formatted content of every file that would change under
proposed_changes, so automation can apply the result without a second run. Each document reports
ok (formatting is clean and nothing failed; for --write, every write succeeded) and an errors
array of {path, message} entries for unreadable files or failed directory walks. The exit code is
1 when --check-formatted finds unformatted files, and in every JSON mode when errors is
non-empty; dry-run and stdin JSON still exit 0 when changes are merely proposed.
Run RustyWind with a custom sorter. The config_file.json should have a top level entry of sortOrder
which is an array with the classes listed in the order you want them sorted.
rustywind --config-file config_file.jsonUse with tailwind prettier plugin
rustywind --output-css-file
rustywind --vite-css
…Inspired by Ryan Heybourn's headwind vscode plugin. This is a CLI tool that will look through your project and sort all Tailwind CSS classes.
It will also delete any duplicate classes it finds.
See RELEASE.md for release directions.
No open issues yet, or sync has not completed.