https://github.com/bitcrowd/rehype-sort-tailwind-classes
Sort Tailwind CSS classes in HTML
https://github.com/bitcrowd/rehype-sort-tailwind-classes
rehype rehype-plugin tailwindcss
Last synced: 2 months ago
JSON representation
Sort Tailwind CSS classes in HTML
- Host: GitHub
- URL: https://github.com/bitcrowd/rehype-sort-tailwind-classes
- Owner: bitcrowd
- License: mit
- Created: 2021-09-26T08:00:17.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T11:37:42.000Z (over 3 years ago)
- Last Synced: 2025-10-22T15:11:53.089Z (8 months ago)
- Topics: rehype, rehype-plugin, tailwindcss
- Language: TypeScript
- Homepage: https://npmjs.com/package/rehype-sort-tailwind-classes
- Size: 54.7 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rehype-sort-tailwind-classes
Sort Tailwind CSS classes in HTML.
[](https://github.com/bitcrowd/rehype-sort-tailwind-classes/actions/workflows/main.yml)
## Install
This package is [ESM-only][esm]: Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
[npm][]:
```sh
npm install rehype-sort-tailwind-classes
```
This package exports no identifiers. The default export is `rehypeSortTailwindClasses`.
## Use
On the API:
```diff
import { unified } from 'unified';
import rehypeParse from 'rehype-parse';
+import rehypeSortTailwindClasses from 'rehype-sort-tailwind-classes';
import rehypeStringify from 'rehype-stringify';
unified()
.use(rehypeParse)
+ .use(rehypeSortTailwindClasses)
.use(rehypeStringify)
.process('some html', function (err, file) {
console.error(report(err || file));
console.log(String(file));
});
```
On the CLI:
```sh
rehype input.html --use rehype-sort-tailwind-classes --output output.html
```
## Example
##### In
```html
```
##### Out
```html
```
## Options
The plugin accepts any options supported by [Tailwind Classes Sorter][tcs].
Additionally, it supports a `pluginOrder: string[]` option to augment the default plugin ordering.
## License
[MIT](./LICENSE)
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://docs.npmjs.com/cli/install
[tcs]: https://github.com/Acidic9/tailwind-classes-sorter