How to access tailwind classes from a javascript file

Viewed 719

I've just started with tailwind-css and I am trying to change the color of a HTML element using tailwindcss.

This is the HTML code - <h1 id="demo" class="text-3xl font-bold tracking-wide text-center">Hello</h1>.

And this is the Javascript code - document.getElementById("demo").style.color = "text-blue-600";.

vanilla CSS works but I am not able to access the tailwind utility classes.

1 Answers

You can use npm install -D tailwindcss@latest postcss@latest autoprefixer@latest or use <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"> but using the tag won't benefit alot so its better to install it with NPM

Related