Tailwind-CSS-Classes-Not-Applied-in-Dynamically-Generated-Template-Literals-pkogz Tailwind Templates

Tailwind Css Classes Not Applied In Dynamically Generated Template Literals Pkogz

Tailwind CSS classes not applied when dynamically generated inside JavaScript template literals. The issue occurs due to the way Tailwind processes classes generated dynamically within backticks.

Tailwind CSS Dynamic Class Application Bug

This repository demonstrates a bug related to applying Tailwind CSS classes when they are dynamically generated within JavaScript template literals. The issue occurs because Tailwind's class parsing mechanism might not correctly interpret classes created dynamically within backticks.

Bug Description

When using a JavaScript variable to generate a Tailwind class name within a template literal (e.g., using backticks), the class might not be correctly applied. This leads to the style not being rendered.

Solution

The solution involves creating a function that joins the classes with the "className" attribute or using the spread syntax directly in the JSX expression if you're using React.

Top categories

Loading Svelte Themes