Skip to content

Doesn't work with Astro #451

Open
Open

Description

@alexschcom

What version of prettier-plugin-tailwindcss are you using?

v0.7.2

What version of Tailwind CSS are you using?

v4.2.0

What version of Node.js are you using?

v22.20.0

What package manager are you using?

npm

What operating system are you using?

macOS

Reproduction URL

https://github.com/alexschcom/prettier-plugin-tailwindcss-issue

Describe your issue

/src/pages/index.astro → <h1> class list should change

<h1 class="p-4 text-9xl m-4">Astro</h1>

to

<h1 class="m-4 p-4 text-9xl">Astro</h1>

Activity

  1. victormscn commented on Feb 21, 2026

    @victormscn

    Same for the latest version of Angular

  2. inomish commented on Jun 7, 2026

    @inomish

    Neither with svelte

  3. Eptagone commented on Sep 23, 2026

    @Eptagone

    This used to work before. Now it doesn't

  4. pmdci commented on Sep 27, 2026

    @pmdci

    Happened to me in Astro 7 as well.

    prettier-plugin-tailwindcss (0.8.1) does not sort classes in .astro files with prettier-plugin-astro 1.x — the 1.x parser emits a JSX-shaped AST (AstroRoot/JSXElement/ JSXAttribute) the Tailwind plugin does not walk. .tsx is sorted normally.

  5. dauniel000 commented on Sep 29, 2026

    @dauniel000

    commit #473 resolved the issue

    steps i did using bun

    # clone & enter repo
    git clone https://github.com/tailwindlabs/prettier-plugin-tailwindcss.git && cd prettier-plugin-tailwindcss
    
    # install dependencies & build project (creates /dist folder)
    bun install && bun run build
    
    # link plugin globally
    bun link
    
    # link plugin in your project
    cd ../your-project
    bun link prettier-plugin-tailwindcss # or add to this line to deps "prettier-plugin-tailwindcss": "link:prettier-plugin-tailwindcss"

    this is my .prettierrc configuration

    {
    	"plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
    	"tailwindStylesheet": "./src/styles/global.css",
    	"overrides": [
    		{
    			"files": "*.astro",
    			"options": {
    				"parser": "astro"
    			}
    		}
    	]
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions