Socket
Socket
Sign inDemoInstall

prettier-plugin-tailwindcss

Package Overview
Dependencies
1
Maintainers
4
Versions
144
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    prettier-plugin-tailwindcss

A Prettier plugin for sorting Tailwind CSS classes.


Version published
Weekly downloads
1.4M
decreased by-15.99%
Maintainers
4
Install size
648 kB
Created
Weekly downloads
 

Package description

What is prettier-plugin-tailwindcss?

The prettier-plugin-tailwindcss npm package is a plugin for Prettier, the code formatter, that sorts Tailwind CSS classes automatically. It ensures that your Tailwind CSS classes are ordered consistently according to the recommended order from the Tailwind CSS documentation. This can help improve readability and maintainability of your code.

What are prettier-plugin-tailwindcss's main functionalities?

Sorting Tailwind CSS classes

This plugin will reorder the classes to follow the default Tailwind CSS order, for example, positioning classes like 'flex' and 'justify-center' would come before display and box model classes like 'p-4' and 'bg-red-500'.

"<div class='bg-red-500 p-4 flex justify-center'>Hello World</div>"

Other packages similar to prettier-plugin-tailwindcss

Changelog

Source

[0.1.13] - 2022-07-25

Fixed

  • Fix error when using Angular pipes (#86)

Readme

Source

prettier-plugin-tailwindcss

A Prettier plugin for Tailwind CSS that automatically sorts classes based on Tailwind's internal class sorting algorithm.

Note, this plugin is only compatible with Tailwind CSS v3.

Installation

Install prettier-plugin-tailwindcss via npm as a dev-dependency.

npm install --save-dev prettier prettier-plugin-tailwindcss

This plugin follows the Prettier autoloading convention, so once it's installed it should automatically start working.

Resolving your Tailwind configuration

By default this plugin will look for a Tailwind configuration file (tailwind.config.js) in the same directory as your Prettier configuration file.

If your Tailwind configuration file 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 Tailwind configuration file cannot be found then the default Tailwind configuration will be used.

Compatibility with other Prettier plugins

To make this plugin work, we had to build it in a way that the Prettier plugin system was not designed for. We had to extend the core parsers in Prettier with our own custom parsers. And while this works, it makes this plugin incompatible with other Prettier plugins that are build the same way. This is a known limitation of Prettier.

One example of this incompatibility is with the prettier-plugin-svelte plugin. It's not possible to use the Svelte plugin at the same time as the Tailwind CSS plugin. However, as a workaround, we bundled the Svelte plugin into this plugin. Simply remove prettier-plugin-svelte from your Svelte project when installing the prettier-plugin-tailwindcss plugin, and everything should work fine.

FAQs

Last updated on 21 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc