A Prettier plugin that sorts and formats Tailwind CSS classes within twin.macro template literals and JSX tw attributes. Current stable version is 1.0.14. It follows Tailwind's recommended class order and supports grouping by variant, bracket groups with !important, and arbitrary CSS. Released under the MIT license with a focus on twin.macro integration, unlike general Tailwind Prettier plugins. The plugin is actively maintained with frequent releases addressing regex improvements and bug fixes.
npm install prettier-plugin-twin.macroVerified import paths — ran on the pinned version, not inferred.
Demonstrates installing the plugin, configuring prettier.config.js, and formatting a twin.macro tw attribute with Tailwind classes.
Downgrade Prettier to v2.x or wait for plugin update supporting v3.
Update twin.macro to v3 and adjust import paths if needed.
Use twin.macro's built-in tw prop or template literals for sorting.
Review diff after formatting; can disable grouping via plugin options if undesired.
Ensure tailwind.config.js exists or set twin.macroConfig in Prettier config.
Create a tailwind.config.js in your project root or set `twin.macroConfig` in prettier.config.js to point to an existing config.
Use `require('prettier-plugin-twin.macro')` in CommonJS, or use `import pkg from 'prettier-plugin-twin.macro'; const plugin = pkg.default || pkg;` in ESM.Run `npm install --save-dev prettier-plugin-twin.macro prettier` or `yarn add -D prettier-plugin-twin.macro prettier`.