Tailwind CSS
RubyMine integrates with the Tailwind CSS framework including completion for Tailwind classes in HTML files and completion suggestions for pseudo-class variants, preview of the resulting CSS on hovering over classes in HTML and CSS files or on autocompletion. RubyMine recognizes tailwind.config.js files and provides completion based on customization you make to them.
Before you start
Make sure you have Node.js on your computer.
Make sure the CSS bundled plugin is enabled in the Installed tab of the Settings/Preferences | Plugins page as described in Managing plugins.
Install and enable the Tailwind CSS plugin on the Settings/Preferences | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains repository.
Install Tailwind CSS
Open the embedded Terminal (Alt+F12) and type:
npm install tailwindcss postcss autoprefixer
To configure your Tailwind CSS installation, generate a tailwind.config.js configuration file in the root of your project. In the embedded Terminal (Alt+F12) , type:
npx tailwindcss init
Learn more from the Tailwind CSS official website.
Complete Tailwind classes
RubyMine autocompletes Tailwind classes in HTML files and in CSS files after the @apply
directive.
![Completing Tailwind classes after @apply directive Completing Tailwind classes after @apply directive](https://resources.jetbrains.com/help/img/idea/2021.3/ws_tailwind-completion-after-apply.png)
RubyMine suggests Tailwind classes for completion in JavaScript string literals.
![Completion for Tailwind classes in JavaScript string literals Completion for Tailwind classes in JavaScript string literals](https://resources.jetbrains.com/help/img/idea/2021.3/ws_tailwind_completion_for_js_string_literals_light.png)
Completion suggestions are also shown for pseudo-class variants.
![Completion suggestions for pseudo-class variants Completion suggestions for pseudo-class variants](https://resources.jetbrains.com/help/img/idea/2021.3/ws_tailwind-completion-for-pseudo-class-variants.png)
Preview the resulting CSS
When you hover over a Tailwind class in an HTML or CSS file, RubyMine shows you the preview of the resulting CSS.
The preview is also shown in the Documentation popup (Ctrl+Q) when you complete your code.
![Preview the resulting CSS while completing code Preview the resulting CSS while completing code](https://resources.jetbrains.com/help/img/idea/2021.3/ws_tailwind_css_preview_completion.png)
Edit your tailwind.config.js
RubyMine provides code completion based on the customization you make through your tailwind.config .js configuration files. For example, if you define a custom theme with new colors, newly generated classes with the name of the custom color will be shown in the completion popup.
![Completion based on customization in tailwind.config.js Completion based on customization in tailwind.config.js](https://resources.jetbrains.com/help/img/idea/2021.3/ws_tailwind_css_edit_config.png)