如何在旧类上覆盖 tailwind 类,例如 css 中的 !important

问题描述 投票:0回答:1

我在

text-[20px]
中使用了
<Badge/>
,但它被另一个css类覆盖了,我如何覆盖
tailwind

<Badge
  label="1"
  className='w-[30px] h-[30px] p-6 ml-4 text-[20px]'
  style={{ lineHeight: '20px'}}>
  1
</Badge>

css tailwind-css react-bootstrap tailwind-ui
1个回答
0
投票

如果你想覆盖其他类上的

text-[20px]
,你可以这样编写类:

 <Badge
   label="1"
   className='w-[30px] h-[30px] p-6 ml-4 [&&]:text-[20px]'
   style={{ lineHeight: '20px'}}>
   1
 </Badge>

© www.soinside.com 2019 - 2024. All rights reserved.