tailwind
> Prettier configuration with Tailwind CSS class sorting. Extends @jmlweb/prettier-config-base.
> π§ Maintenance mode: dependency and security updates only, no new rules. New projects should use @jmlweb/oxfmt-config-base with its sortTailwindcss option. To migrate, see the migration guide.
β¨ Features
Section titled ββ¨ Featuresβ- π¨ Class sorting: orders Tailwind classes in the recommended order
- π§ Base included: inherits every setting from
@jmlweb/prettier-config-base - π¦ Plugin bundled: ships
prettier-plugin-tailwindcssas a dependency - π Zero config: works out of the box
π¦ Installation
Section titled βπ¦ Installationβnpm install --save-dev @jmlweb/prettier-config-tailwind prettier> π‘ Upgrading? See the Migration Guide.
π Quick Start
Section titled βπ Quick StartβCreate .prettierrc.mjs:
export { default } from '@jmlweb/prettier-config-tailwind';Alternatives:
{ "prettier": "@jmlweb/prettier-config-tailwind"}> β οΈ In projects with "type": "module", the package.json field can make Prettier warn Ignored unknown option { default: ... } and skip the config (no class sorting). Use .prettierrc.mjs instead.
For CommonJS (.prettierrc.cjs):
module.exports = require('@jmlweb/prettier-config-tailwind');π‘ Examples
Section titled βπ‘ ExamplesβBefore:
<button className="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600"> Click me</button>After:
<button className="rounded-lg bg-blue-500 px-4 py-2 text-white hover:bg-blue-600"> Click me</button>π Configuration Details
Section titled βπ Configuration DetailsβThe config is the base config plus:
| Option | Value | Description |
|---|---|---|
plugins |
['prettier-plugin-tailwindcss'] |
Sorts Tailwind CSS classes |
π― When to Use
Section titled βπ― When to Useβ- β Projects using Tailwind CSS
- β Automatic, consistent class order
Not for you if:
- No Tailwind: use
@jmlweb/prettier-config-base - New projects: use
@jmlweb/oxfmt-config-base
π§ Extending the Configuration
Section titled βπ§ Extending the Configurationβimport tailwindConfig from '@jmlweb/prettier-config-tailwind';
export default { ...tailwindConfig, printWidth: 100,};π Usage with Scripts
Section titled βπ Usage with Scriptsβ{ "scripts": { "format": "prettier --write .", "format:check": "prettier --check ." }}npm run format # format all filesnpm run format:check # check without writingπ Requirements
Section titled βπ Requirementsβ- Node.js >= 22.12.0
- Prettier >= 3.0.0
π¦ Peer Dependencies
Section titled βπ¦ Peer Dependenciesβprettier(^3.0.0)
prettier-plugin-tailwindcss is a regular dependency, so it needs no separate install.
π Related Packages
Section titled βπ Related Packagesβ@jmlweb/prettier-config-base- Base config extended by this package@jmlweb/oxfmt-config-base- Recommended Oxfmt replacement
π Migration Guide
Section titled βπ Migration Guideβ1.x to 2.0
Section titled β1.x to 2.0βBreaking: Node.js >= 22.12.0 is required (18 and 20 are end-of-life).
- Upgrade Node.js to 22.12.0 or later.
- Update:
npm install --save-dev @jmlweb/prettier-config-tailwind@latest
See the Changelog for details.
π License
Section titled βπ LicenseβMIT