Comments (24)
Thanks for looking into this. I've handled CSS formatting in the past so I figured I'd offer some of that experience to this issue.
Existing Approaches
For developers that care about the order of CSS properties, there are two predominant approaches:
- Group by type
- Alphabetical
Group by type makes the most sense for Tailwind because alphabetical would result in a messy mix of variant classes.
Recommended Order
- Non-Tailwind Classes
- Non-variant classes grouped by type
- Pseudo-Class Variants grouped by type
- Responsive Variants grouped by type, escalating from smallest to largest breakpoint
Recommended Grouping
Grouping CSS properties by type has been handled in a number of formatters such as CSScomb. You might consider borrowing the groupings from CSScomb's default config.
If you define the order in a JSON config, it may even be possible for users to override it with a custom JSON config in VS code settings.
from tailwindcss-intellisense.
I did make an eslint plugin for this classnames ordering, it reads your tailwind config and you can configure the order if you want:
https://www.npmjs.com/package/eslint-plugin-tailwindcss
from tailwindcss-intellisense.
This VSC extension takes care of all the things: https://marketplace.visualstudio.com/items?itemName=heybourn.headwind
from tailwindcss-intellisense.
Closing this as we have no plans to add class formatting to Tailwind CSS IntelliSense. We are working on an alternative class sorting solution, so look out for that in the near future 👀
from tailwindcss-intellisense.
I wonder if we could borrow from how stylelint-order lets you customize it via json. https://gist.github.com/octoxan/1c0c24a75417f06096356e07d56be3c6
from tailwindcss-intellisense.
@huphtur headwind is cool but still has a lot of unsolved edge-cases: like no support for prefixed classes, missing classes from the latest TW versions, templated strings, etc. Would be really happy to see that supported by intellisense
from tailwindcss-intellisense.
I'd switch to VS Code from PHP Storm if this becomes a thing lol
from tailwindcss-intellisense.
Alternative solution is a plugin for prettier I think https://github.com/tailwindlabs/prettier-plugin-tailwindcss. Looks very good, but unfortunately prettier is not available for my programming language, ReScript.
So if there is no plans to integrate it into the extension, we have to use separate extension for sorting, I think.
from tailwindcss-intellisense.
Waiting for this feature so much!
from tailwindcss-intellisense.
any updates?
from tailwindcss-intellisense.
What class name ordering does tailwindui use? Perhaps that could be the opinionated method of declaring class name order.
from tailwindcss-intellisense.
I'd love if you could specify the ordering of properties, as everyone is very specific in their workflow once you start ordering properties a certain way, and maybe a dropdown option for non-tailwind classes to be at the start or end?
from tailwindcss-intellisense.
- Suggest putting those first in the order as it could contain extracted components classes.
eg:<button class="btn bg-green-500 hover:bg-green-400 text-white">
from tailwindcss-intellisense.
css-declaration-sorter may be of good use as well.
from tailwindcss-intellisense.
Has anyone done some work towards that so far? I'd love to have that thingy automated away from my thoughflow :)
from tailwindcss-intellisense.
This would be the biggest improvement I can think of for the tailwindcss experience
from tailwindcss-intellisense.
Any updates on this front so far? Can't wait to see this live!
from tailwindcss-intellisense.
@bradlc Headwind seems to fix this issue. It is popular and actively maintained.
No need to reinvent the wheel, right?
from tailwindcss-intellisense.
@bradlc Headwind seems to fix this issue. It is popular and actively maintained.
No need to reinvent the wheel, right?
Just tried Headwind. It currently can't sort variant classes with md:
, lg:
, etc.. They will be treated as "custom classes" and be appended to the end. Something like text-center sm:ml-auto md:text-left ml-2
will be formatted into something like ml-2 text-center sm:ml-auto md:text-left
instead of ml-2 sm:ml-auto text-center md:text-left
, which is not good yet.
from tailwindcss-intellisense.
@1isten The PR that tackled this issue was closed. I think it is personal preference, where the variant classes should be sorted.
from tailwindcss-intellisense.
it is personal preference
@cajakre Yep. After all there is no correct ordering. @bradlc 's example here just makes more sense to me. XD
from tailwindcss-intellisense.
@francoismassart Thanks, I will try that!
from tailwindcss-intellisense.
@bradlc please reference this issue when your alternative class sorting solution is made public.
from tailwindcss-intellisense.
so there is an emacs lsp-mode https://github.com/merrickluo/lsp-tailwindcss based on https://github.com/tailwindlabs/tailwindcss-intellisense and it use https://github.com/avencera/rustywind that is inspired by https://github.com/heybourn/headwind an non prettier class sorting that is obsolete
problem is prettier hard to setup especially when you use template engine like .erb
when I use headwind I just install the extension and its just works,
with prettier I got tangled by the settings and npm dependencies hell
from tailwindcss-intellisense.
Related Issues (20)
- not getting suggestions of tailwindcss intellisense HOT 1
- Regression between NPM releases 0.0.16 and 0.0.17 — Not working in Neovim HOT 20
- Failed to parse custom class regex in neovim HOT 2
- LSP broken on NVim(AstroNvim) with exit code 1 after latest update HOT 3
- tailwindCSS.experimental.classRegex breaks after Version 10.5 HOT 2
- Project paths with parentheses not working (v0.12.x) HOT 3
- tailwindcss-intellisense extension not working properly HOT 4
- Parser is reading (some) comments as classes HOT 1
- Notification of breaking api change with v1.92 release of VS Code HOT 2
- Tailwind css intellisense not working HOT 1
- VSCode 1.91 breaks code actions HOT 7
- tailwindCSS.emmetCompletions set not work HOT 1
- Failed to read configuration (d:\xxx\xxx\tailwind.config.js) HOT 6
- bun runtime support HOT 4
- False cssConflict Issue HOT 1
- [NextUI] extendVariants is not triggering intellisense in a Turborepo HOT 2
- Tailwind Intellisense not working with .vue files HOT 3
- Intellisense not working in Angular Decorator
- Wrong styles displaying when multiple configs are in the webroot (since v0.12)
- [postcss] input.split is not a function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tailwindcss-intellisense.