Home > Enterprise >  Add tailwind classes manually
Add tailwind classes manually

Time:02-14

I use a tailwind class, which is only add with JS afterwards. However, when I generate the css from tailwind this CSS class is of course not included. Therefore the question how I can add this class.

CodePudding user response:

You will need to configure Tailwind so that it will also scan your JS files that are adding these additional classes. This can be done by modifying tailwind.config.js file and add additional entries/glob patterns to the content array, as per documentation.

Under the hood Tailwind CSS uses regex to simply search for possible classname uses in JS files. This also means that you need to be mindful of how you're adding classes in JS. You cannot use dynamically composited class names, e.g. const className = 'px-' SOME_NUMBER, because Tailwind CSS cannot guess the class name.

CodePudding user response:

You can customize Tailwind CSS by changing lines under themes section in your tailwind.config.js file. About more details: Tailwind Custom Styles

  • Related