简体   繁体   English

ReactJS:Tailwind 覆盖全局 CSS 内联

[英]ReactJS: Tailwind override global CSS inline

I have this rails reactjs app that if I put this line in the form我有这个 rails reactjs 应用程序,如果我把这一行放在表格中

<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.我刚刚安装了 Tailwind,如果我用 tailwind class 输入这一行,它对按钮设计没有任何影响。

<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.任何帮助将不胜感激。

You can add a !您可以添加一个! character before the class name and that should do the job class 名称之前的字符,应该可以完成工作

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文档: https://v2.tailwindcss.com/docs/just-in-time-mode#built-in-important-modifier

Yes, You can config tailwind.config.js if you add this是的,如果你添加这个,你可以配置tailwind.config.js

module.exports = {
  important: true,
}

this will generate all tailwind classes as !important这将生成所有tailwind类作为!important

read more here在这里阅读更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM