Prettier Plugin Classnames screenshot

Prettier Plugin Classnames

Author Avatar Theme by Ony3000
Updated: 17 Jan 2026
191 Stars

A Prettier plugin that wraps verbose class name based on the `printWidth` option.

Overview

If you’re a developer who often works with CSS in JavaScript frameworks, the prettier-plugin-classnames is a game-changer for your workflow. This Prettier plugin offers a robust way to manage and simplify verbose class names throughout your code, enhancing readability and maintainability. With compatibility for various Prettier versions and a plethora of configuration options, it streamlines the formatting process so you can focus more on coding and less on formatting quirks.

This tool is especially useful for those who may struggle with long class names that exceed common print width limits. By wrapping these class names intelligently, it not only improves the appearance of your code but also maintains functional integrity across different setups.

Features

  • Custom Attributes: Easily define a list of custom attributes for class names, enhancing flexibility with existing ones being fully supported.

  • Custom Functions: Utilize the built-in classNames function or introduce your own functions to handle class name collections, allowing for tailored formatting.

  • Ending Position Options: Choose between ‘absolute’ and ‘relative’ options to specify how class names end on each line, catering to your preferred styling needs.

  • Syntax Transformation: Automatically transform non-expression syntax to expression syntax on line wraps, although this transformation is not reversible.

  • Version Correlation: Stay up-to-date with synchronization between this plugin and its sibling plugins to ensure seamless functionality.

  • Compatibility with Other Plugins: Easily integrate with other Prettier plugins like prettier-plugin-merge to ensure that your code formatting is both comprehensive and efficient.

  • Installation Flexibility: Simple installation process which ensures that users with various versions can set up the plugin without hassle.