DEV Community

Muhammad Arief Rahman
Muhammad Arief Rahman

Posted on

3

Making TailwindCSS IntelliSense Work with Phlex in VSCode

When working with Phlex—Ruby's object-oriented view component library—you might notice that TailwindCSS IntelliSense doesn't work out of the box. This happens because Phlex components are defined in Ruby files, which TailwindCSS doesn't recognize by default.

The Problem

In Phlex, you write HTML using Ruby syntax:

div class: "flex items-center justify-between" do
  # content here
end
Enter fullscreen mode Exit fullscreen mode

But VSCode's TailwindCSS extension won't provide autocomplete or linting for these classes.

The Solution

Add these custom settings to your VSCode configuration:

{
  "tailwindCSS.includeLanguages": {
    "ruby": "html"
  },
  "[ruby]": {
    "tailwindCSS.experimental.classRegex": [
      "\\bclass:\\s*[\"']([^\"']*)[\"']",
    ]
  },
  "[erb]": {
    "tailwindCSS.experimental.classRegex": [
      "\\bclass:\\s*[\"']([^\"']*)[\"']",
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

This configuration does two important things:

  1. Tells the Tailwind extension to treat Ruby files as HTML
  2. Provides a regex pattern to identify Tailwind classes in both Ruby and ERB files

Happy coding with Phlex and Tailwind!

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Image of Datadog

Get the real story behind DevSecOps

Explore data from thousands of apps to uncover how container image size, deployment frequency, and runtime context affect real-world security. Discover seven key insights that can help you build and ship more secure software.

Read the Report

👋 Kindness is contagious

Dive into this thoughtful article, cherished within the supportive DEV Community. Coders of every background are encouraged to share and grow our collective expertise.

A genuine "thank you" can brighten someone’s day—drop your appreciation in the comments below!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found value here? A quick thank you to the author makes a big difference.

Okay