prettier-plugin-tailwindcss
A Prettier plugin for sorting Tailwind CSS classes.
Last updated 2 years ago by thecrypticace .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install prettier-plugin-tailwindcss 
SYNC missed versions from official npm registry.
prettier-plugin-tailwindcss

A Prettier plugin for Tailwind CSS v3.0+ that automatically sorts classes based on our recommended class order.

Installation

To get started, just install prettier-plugin-tailwindcss as a dev-dependency:

npm install -D prettier prettier-plugin-tailwindcss

This plugin follows Prettier’s autoloading convention, so as long as you’ve got Prettier set up in your project, it’ll start working automatically as soon as it’s installed.

Note that plugin autoloading is not supported when using certain package managers, such as pnpm or Yarn PnP. In this case you may need to add the plugin to your Prettier config explicitly:

// prettier.config.js
module.exports = {
  plugins: [require('prettier-plugin-tailwindcss')],
}

Resolving your Tailwind configuration

To ensure that the class sorting is taking into consideration any of your project's Tailwind customizations, it needs access to your Tailwind configuration file (tailwind.config.js).

By default the plugin will look for this file in the same directory as your Prettier configuration file. However, if your Tailwind configuration is somewhere else, you can specify this using the tailwindConfig option in your Prettier configuration.

Note that paths are resolved relative to the Prettier configuration file.

// prettier.config.js
module.exports = {
  tailwindConfig: './styles/tailwind.config.js',
}

If a local configuration file cannot be found the plugin will fallback to the default Tailwind configuration.

Compatibility with other Prettier plugins

This plugin uses Prettier APIs that can only be used by one plugin at a time, making it incompatible with other Prettier plugins implemented the same way. To solve this we've added explicit per-plugin workarounds that enable compatibility with the following Prettier plugins:

  • @prettier/plugin-php
  • @prettier/plugin-pug
  • @shopify/prettier-plugin-liquid
  • @ianvs/prettier-plugin-sort-imports
  • @trivago/prettier-plugin-sort-imports
  • prettier-plugin-astro
  • prettier-plugin-css-order
  • prettier-plugin-import-sort
  • prettier-plugin-jsdoc
  • prettier-plugin-organize-attributes
  • prettier-plugin-organize-imports
  • prettier-plugin-style-order
  • prettier-plugin-svelte
  • prettier-plugin-twig-melody

One limitation with this approach is that prettier-plugin-tailwindcss must be loaded last, meaning Prettier auto-loading needs to be disabled. You can do this by setting the pluginSearchDirs option to false and then listing each of your Prettier plugins in the plugins array:

// .prettierrc
{
  // ..
  "plugins": [
    "prettier-plugin-svelte",
    "prettier-plugin-organize-imports",
    "prettier-plugin-tailwindcss" // MUST come last
  ],
  "pluginSearchDirs": false
}

Current Tags

  • 0.2.0-beta.3                                ...           beta (2 years ago)
  • 0.0.0-insiders.90b0253                                ...           insiders (17 days ago)
  • 0.6.9                                ...           latest (a month ago)

184 Versions

  • 0.0.0-insiders.90b0253                                ...           17 days ago
  • 0.6.9                                ...           a month ago
  • 0.0.0-insiders.cdbc764                                ...           a month ago
  • 0.0.0-insiders.962e4ed                                ...           a month ago
  • 0.0.0-insiders.9e58db2                                ...           a month ago
  • 0.0.0-insiders.9ce7d37                                ...           a month ago
  • 0.0.0-insiders.26a4754                                ...           a month ago
  • 0.6.8                                ...           3 months ago
  • 0.0.0-insiders.64373cf                                ...           3 months ago
  • 0.0.0-insiders.081b4f5                                ...           3 months ago
  • 0.0.0-insiders.d4f80ab                                ...           3 months ago
  • 0.6.7                                ...           3 months ago
  • 0.0.0-insiders.b1e25fd                                ...           3 months ago
  • 0.0.0-insiders.385e7c2                                ...           3 months ago
  • 0.0.0-insiders.cdb3b98                                ...           3 months ago
  • 0.0.0-insiders.15e8009                                ...           4 months ago
  • 0.0.0-insiders.9844623                                ...           4 months ago
  • 0.6.6                                ...           5 months ago
  • 0.0.0-insiders.0368ffb                                ...           5 months ago
  • 0.0.0-insiders.b7830c6                                ...           5 months ago
  • 0.0.0-insiders.ee50b9b                                ...           6 months ago
  • 0.0.0-insiders.f69f739                                ...           6 months ago
  • 0.0.0-insiders.c0c5040                                ...           6 months ago
  • 0.0.0-insiders.c5eed72                                ...           6 months ago
  • 0.0.0-insiders.f101793                                ...           6 months ago
  • 0.0.0-insiders.031e5f1                                ...           6 months ago
  • 0.6.5                                ...           6 months ago
  • 0.0.0-insiders.efea6f9                                ...           6 months ago
  • 0.0.0-insiders.642a97c                                ...           6 months ago
  • 0.0.0-insiders.a5506a9                                ...           6 months ago
  • 0.0.0-insiders.ec92b76                                ...           6 months ago
  • 0.6.4                                ...           6 months ago
  • 0.0.0-insiders.2a9d702                                ...           6 months ago
  • 0.0.0-insiders.a13021c                                ...           6 months ago
  • 0.0.0-insiders.0ea2dc0                                ...           6 months ago
  • 0.0.0-insiders.9b9bfe4                                ...           6 months ago
  • 0.6.3                                ...           6 months ago
  • 0.0.0-insiders.bd3d5b0                                ...           6 months ago
  • 0.0.0-insiders.1010b51                                ...           6 months ago
  • 0.0.0-insiders.b047e02                                ...           6 months ago
  • 0.0.0-insiders.6ded534                                ...           6 months ago
  • 0.6.2                                ...           7 months ago
  • 0.0.0-insiders.aa6ec0a                                ...           7 months ago
  • 0.0.0-insiders.57afde1                                ...           7 months ago
  • 0.0.0-insiders.82ea71a                                ...           7 months ago
  • 0.6.1                                ...           7 months ago
  • 0.0.0-insiders.731ae22                                ...           7 months ago
  • 0.0.0-insiders.8a9094f                                ...           7 months ago
  • 0.6.0                                ...           7 months ago
  • 0.0.0-insiders.afbc487                                ...           7 months ago
  • 0.0.0-insiders.1f83aae                                ...           7 months ago
  • 0.5.14                                ...           8 months ago
  • 0.0.0-insiders.3c9ce4e                                ...           8 months ago
  • 0.0.0-insiders.3df9921                                ...           8 months ago
  • 0.0.0-insiders.360cb77                                ...           9 months ago
  • 0.0.0-insiders.b4aa821                                ...           9 months ago
  • 0.5.13                                ...           9 months ago
  • 0.0.0-insiders.3201e5f                                ...           9 months ago
  • 0.0.0-insiders.d66a6d5                                ...           9 months ago
  • 0.0.0-insiders.35fe358                                ...           9 months ago
  • 0.0.0-insiders.54f0d43                                ...           9 months ago
  • 0.0.0-insiders.10e0c19                                ...           9 months ago
  • 0.5.12                                ...           10 months ago
  • 0.0.0-insiders.f563336                                ...           10 months ago
  • 0.0.0-insiders.b019552                                ...           10 months ago
  • 0.0.0-insiders.81c446e                                ...           10 months ago
  • 0.0.0-insiders.1fa24c2                                ...           a year ago
  • 0.0.0-insiders.4338bd0                                ...           a year ago
  • 0.5.11                                ...           a year ago
  • 0.0.0-insiders.bf40417                                ...           a year ago
  • 0.0.0-insiders.08f5c4c                                ...           a year ago
  • 0.5.10                                ...           a year ago
  • 0.0.0-insiders.885b14f                                ...           a year ago
  • 0.0.0-insiders.9f8780c                                ...           a year ago
  • 0.5.9                                ...           a year ago
  • 0.0.0-insiders.e3229c2                                ...           a year ago
  • 0.0.0-insiders.fa38999                                ...           a year ago
  • 0.5.8                                ...           a year ago
  • 0.0.0-insiders.dd4bfce                                ...           a year ago
  • 0.0.0-insiders.4cc6319                                ...           a year ago
  • 0.0.0-insiders.cf301ca                                ...           a year ago
  • 0.5.7                                ...           a year ago
  • 0.0.0-insiders.38f2be3                                ...           a year ago
  • 0.0.0-insiders.92f10af                                ...           a year ago
  • 0.0.0-insiders.15c1196                                ...           a year ago
  • 0.5.6                                ...           a year ago
  • 0.0.0-insiders.c51df4d                                ...           a year ago
  • 0.0.0-insiders.2968765                                ...           a year ago
  • 0.0.0-insiders.b5a251e                                ...           a year ago
  • 0.5.5                                ...           a year ago
  • 0.0.0-insiders.12d175e                                ...           a year ago
  • 0.0.0-insiders.047d591                                ...           a year ago
  • 0.0.0-insiders.b300077                                ...           a year ago
  • 0.0.0-insiders.38fed86                                ...           a year ago
  • 0.5.4                                ...           a year ago
  • 0.0.0-insiders.93fd16d                                ...           a year ago
  • 0.0.0-insiders.3ebd2f9                                ...           a year ago
  • 0.0.0-insiders.7694e65                                ...           a year ago
  • 0.0.0-insiders.be81958                                ...           a year ago
  • 0.0.0-insiders.e5605ec                                ...           a year ago
  • 0.0.0-insiders.14979f4                                ...           a year ago
  • 0.5.3                                ...           a year ago
  • 0.0.0-insiders.3c4989c                                ...           a year ago
  • 0.0.0-insiders.b062544                                ...           a year ago
  • 0.0.0-insiders.468d3bf                                ...           a year ago
  • 0.0.0-insiders.dad4b36                                ...           a year ago
  • 0.5.2                                ...           a year ago
  • 0.0.0-insiders.72cbb6b                                ...           a year ago
  • 0.0.0-insiders.985302f                                ...           a year ago
  • 0.5.1                                ...           a year ago
  • 0.0.0-insiders.4b768f7                                ...           a year ago
  • 0.0.0-insiders.f365a2b                                ...           a year ago
  • 0.5.0                                ...           a year ago
  • 0.0.0-insiders.7dab79c                                ...           a year ago
  • 0.0.0-insiders.ac70a66                                ...           a year ago
  • 0.0.0-insiders.121f4fa                                ...           a year ago
  • 0.0.0-insiders.36f92f3                                ...           a year ago
  • 0.0.0-insiders.ad48889                                ...           a year ago
  • 0.0.0-insiders.e642c31                                ...           a year ago
  • 0.0.0-insiders.1bc4f3e                                ...           a year ago
  • 0.4.1                                ...           a year ago
  • 0.0.0-insiders.f667b21                                ...           a year ago
  • 0.0.0-insiders.a13d661                                ...           a year ago
  • 0.0.0-insiders.dfc23a8                                ...           a year ago
  • 0.4.0                                ...           a year ago
  • 0.0.0-insiders.532a996                                ...           a year ago
  • 0.0.0-insiders.0184e34                                ...           a year ago
  • 0.0.0-insiders.f713976                                ...           a year ago
  • 0.0.0-insiders.6ea4491                                ...           a year ago
  • 0.0.0-insiders.17ceff1                                ...           a year ago
  • 0.0.0-insiders.fe49d70                                ...           a year ago
  • 0.0.0-insiders.4443561                                ...           2 years ago
  • 0.0.0-insiders.0a1b1a6                                ...           2 years ago
  • 0.0.0-insiders.46d60d5                                ...           2 years ago
  • 0.0.0-insiders.59d8f46                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.0.0-insiders.cc1b192                                ...           2 years ago
  • 0.0.0-insiders.d3f787d                                ...           2 years ago
  • 0.0.0-insiders.6ba6faa                                ...           2 years ago
  • 0.0.0-insiders.78bd35b                                ...           2 years ago
  • 0.0.0-insiders.474c344                                ...           2 years ago
  • 0.0.0-insiders.71f41a4                                ...           2 years ago
  • 0.0.0-insiders.fcbe554                                ...           2 years ago
  • 0.0.0-insiders.a78dd6e                                ...           2 years ago
  • 0.0.0-insiders.c5ff418                                ...           2 years ago
  • 0.0.0-insiders.5f9db4b                                ...           2 years ago
  • 0.2.8                                ...           2 years ago
  • 0.0.0-insiders.dfc4f64                                ...           2 years ago
  • 0.0.0-insiders.df84d8f                                ...           2 years ago
  • 0.2.7                                ...           2 years ago
  • 0.0.0-insiders.d539a72                                ...           2 years ago
  • 0.0.0-insiders.af16880                                ...           2 years ago
  • 0.0.0-insiders.70ea7aa                                ...           2 years ago
  • 0.2.6                                ...           2 years ago
  • 0.0.0-insiders.134c19b                                ...           2 years ago
  • 0.0.0-insiders.4815839                                ...           2 years ago
  • 0.0.0-insiders.2aabc3c                                ...           2 years ago
  • 0.0.0-insiders.41c7738                                ...           2 years ago
  • 0.0.0-insiders.7878ea1                                ...           2 years ago
  • 0.0.0-insiders.dfadcf7                                ...           2 years ago
  • 0.0.0-insiders.6533049                                ...           2 years ago
  • 0.2.5                                ...           2 years ago
  • 0.2.4                                ...           2 years ago
  • 0.2.3                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.2.0-beta.3                                ...           2 years ago
  • 0.2.0-beta.2                                ...           2 years ago
  • 0.2.0-beta.1                                ...           2 years ago
  • 0.1.13                                ...           2 years ago
  • 0.1.12                                ...           2 years ago
  • 0.1.11                                ...           3 years ago
  • 0.1.10                                ...           3 years ago
  • 0.1.9                                ...           3 years ago
  • 0.1.8                                ...           3 years ago
  • 0.1.7                                ...           3 years ago
  • 0.1.6                                ...           3 years ago
  • 0.1.5                                ...           3 years ago
  • 0.1.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE