Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Optimize your workflow with Tailwind CSS: Get class completions and hover previews for classes assigned to variables in VScode

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Optimize your workflow with Tailwind CSS: Get class completions and hover previews for classes assigned to variables in VScode


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

TL;DR

This article provides instructions on how to enable auto-completion and hover IntelliSense for TailwindCSS classes in VScode. To do this, users must add a regex to the VScode settings that matches the desired custom HTML attributes (variable names).

If you've been developing apps using TailwindCSS for some time, then it is inevitable that you will or must have already encountered this issue in VScode.

The problem ๐Ÿšง

The problem

When you assign className to a div then you get auto-completion and the applied CSS style when you hover over the added tailwind class.

โšก๏ธ Note: Tailwind CSS IntelliSense VScode extension must be installed in your VScode to get auto-completion and hover IntelliSense.

But if you create a variable called containerClass and then try assigning tailwind classes to it, then you won't get the same IntelliSense, which is fine for most people ๐Ÿค, but if you're a productivity fanatic like me, then this is not acceptable!

First, let's try to understand why doesn't the containerClass gets the same inference.

The why โ“

The Tailwind CSS IntelliSense VScode extension, by default only looks for class, className and ngClass HTML attributes to provide class completions, hover previews, linting, etc.

Search 'tailwindcss' in vscode settings

We can check this by searching for tailwindcss in our VScode settings, and the first result shows us the default HTML attributes for which class completions, hover previews, linting, etc are provided.

Hence we do not get class completions and hover previews when we assign tailwind classes to a variable.

The solution ๐Ÿ’ฐ

By now you've probably already understood what needs to be done to mitigate this.

In settings, after searching for tailwindcss, we need to:

  1. Click on Add Item button

  2. Add regex that matches the desired custom HTML attributes (variable names) - .*Class , .*ClassName .

default setting

Done! โœ…

Now you should be able to get class completions and hover previews when you assign tailwind classes to a variable that ends with Class or ClassName .

Working Solution

Epilogue ๐ŸŒป

For most people, this might not be of the utmost importance, but I am always on the lookout for the tiniest improvements in my Development Experience! Feel free to share any suggestions you might have for me ๐Ÿ˜‡.

Originally, my plan was to compose a Twitter thread about this topic. However, upon further consideration, I discovered that tweets are not very searchable. As a result, I decided to write a more in-depth blog post instead.

If you like quick tips like this then you might also like my other blog posts. I also share a lot of React, Javascript, Typescript, expo, nextjs content on my twitter.

Thank you for taking the time to read this blog! Your support is greatly appreciated.

...



๐Ÿ“Œ Optimize your workflow with Tailwind CSS: Get class completions and hover previews for classes assigned to variables in VScode


๐Ÿ“ˆ 206.71 Punkte

๐Ÿ“Œ Keep your IntelliCode completions fresh with our GitHub Action for Team Completions


๐Ÿ“ˆ 58.56 Punkte

๐Ÿ“Œ Choosing the Right CSS Approach: Tailwind CSS vs Bootstrap vs Vanillaย CSS


๐Ÿ“ˆ 42.92 Punkte

๐Ÿ“Œ Clean Architecture: Theming with Tailwind and CSS Variables


๐Ÿ“ˆ 41.55 Punkte

๐Ÿ“Œ Tailwind CSS: Replacing Complex Classes with @apply


๐Ÿ“ˆ 39.61 Punkte

๐Ÿ“Œ Add Hover Text Without JavaScript Like we Hover on a Userโ€™s Name


๐Ÿ“ˆ 39.45 Punkte

๐Ÿ“Œ How to Override the Properties of a CSS Class Using Another CSS Class


๐Ÿ“ˆ 39.22 Punkte

๐Ÿ“Œ How to Target a CSS Class Inside Another CSS Class


๐Ÿ“ˆ 39.22 Punkte

๐Ÿ“Œ How to Apply Content Property with Hover, Focus, and Active States in Tailwind


๐Ÿ“ˆ 35.99 Punkte

๐Ÿ“Œ How to Apply Hover and Other States with Align Self in Tailwind


๐Ÿ“ˆ 35.99 Punkte

๐Ÿ“Œ How to Use Whitespace Property with Hover, Focus, and Active States of Tailwind


๐Ÿ“ˆ 35.99 Punkte

๐Ÿ“Œ CSS Pseudo-Classes โ€“ How the :is Pseudo-Class Works with Examples


๐Ÿ“ˆ 35.26 Punkte

๐Ÿ“Œ Can a CSS class inherit one or more other classes ?


๐Ÿ“ˆ 35.26 Punkte

๐Ÿ“Œ Build a Tic Tac Toe Game using HTML, CSS, JavaScript, Tailwind CSS and Canvas Confetti


๐Ÿ“ˆ 35.22 Punkte

๐Ÿ“Œ Why Tailwind CSS is still better than StyleX and other CSS libraries


๐Ÿ“ˆ 35.22 Punkte

๐Ÿ“Œ Creating an animated text gradient with Tailwind CSS (and vanilla CSS)


๐Ÿ“ˆ 35.22 Punkte

๐Ÿ“Œ Mozilla Firefox finally supports tab hover previews


๐Ÿ“ˆ 34.96 Punkte

๐Ÿ“Œ Firefox Devs Working on Tab Hover Previews


๐Ÿ“ˆ 34.96 Punkte

๐Ÿ“Œ Fixing Class Composition in Tailwind CSS


๐Ÿ“ˆ 34.09 Punkte

๐Ÿ“Œ Streamline Your Front-End Development with Tailwind Color Matcher for VSCode


๐Ÿ“ˆ 33.98 Punkte

๐Ÿ“Œ Tailwind CSS vs Foundation: A Comparison of CSS Frameworks


๐Ÿ“ˆ 33.44 Punkte

๐Ÿ“Œ Mojo CSS vs. Tailwind: Choosing the best CSS framework


๐Ÿ“ˆ 33.44 Punkte

๐Ÿ“Œ Tailwind CSS vs. CSS Frameworks: A Comprehensive Comparison for UI Design


๐Ÿ“ˆ 33.44 Punkte

๐Ÿ“Œ What is Hoisting in JavaScript | Hoisting Functions, Variables and Classes


๐Ÿ“ˆ 33.23 Punkte

๐Ÿ“Œ Streamline your Workflow with VSCode Dev Containers & Red Hat Images


๐Ÿ“ˆ 32.39 Punkte

๐Ÿ“Œ 10 Lesser-Known Tips to Accelerate Your Workflow in VSCode ๐Ÿš€


๐Ÿ“ˆ 32.39 Punkte

๐Ÿ“Œ Refactoring instance variables to local variables in Rails controllers


๐Ÿ“ˆ 31.62 Punkte

๐Ÿ“Œ Boosting Your Productivity with Zsh-Completions


๐Ÿ“ˆ 31.02 Punkte

๐Ÿ“Œ The Magic of CSS Filters and Hover Effects


๐Ÿ“ˆ 30.99 Punkte

๐Ÿ“Œ Underline And Overline Menu Hover Effect | CSSย Projects


๐Ÿ“ˆ 30.99 Punkte

๐Ÿ“Œ Create reusable button Components with React,Typescript , Tailwind and Tailwind-variants


๐Ÿ“ˆ 30.74 Punkte

๐Ÿ“Œ Script Kit 1.40.62 - An open-source kit to optimize your developer workflow.


๐Ÿ“ˆ 30.52 Punkte

๐Ÿ“Œ How to use virtual desktops in ChromeOS to optimize your workflow


๐Ÿ“ˆ 30.52 Punkte

๐Ÿ“Œ VSCode extensions I use when developing with Tailwind


๐Ÿ“ˆ 30.5 Punkte

๐Ÿ“Œ 4 VSCode extensions I use when developing with Tailwind


๐Ÿ“ˆ 30.5 Punkte











matomo