Home > database >  ReactJS: Tailwind override global CSS inline
ReactJS: Tailwind override global CSS inline

Time:03-24

I have this rails reactjs app that if I put this line in the form

<input type='submit'/>

It will create for me a blue button. I have just installed Tailwind and if I input this line with tailwind class, it does not have any effect on the button design.

<input type='submit'
              className='bg-red-500  text-white font-bold py-2 px-4 rounded-full'/>

Is there a way that I can override this global settings like putting !important inline in the className?

Any help would be greatly appreciated.

CodePudding user response:

You can add a ! character before the class name and that should do the job

Example:

<input type='submit'
             className='!bg-red-500  text-white font-bold py-2 px-4 rounded-full'/>

Docs: https://v2.tailwindcss.com/docs/just-in-time-mode#built-in-important-modifier

CodePudding user response:

Yes, You can config tailwind.config.js if you add this

module.exports = {
  important: true,
}

this will generate all tailwind classes as !important

read more here

  • Related