css - Adding custom variants to TailwindCSS 4 - Stack Overflow

So the time has come to update my boilerplate to Tailwind 4, and I can't work out how to transfer

So the time has come to update my boilerplate to Tailwind 4, and I can't work out how to transfer my custom variant setup. In my Tailwind 3 tailwind.config.js I have this:

plugins: [
    plugin(function({ addVariant }) {
      addVariant('js', '.js &')
      addVariant('no-js', '.no-js &')
    })
  ],

To add a couple of variants. I think I need to use the new @custom-variant in my styles.css file but I can't work out the syntax. Or I may be barking up the wrong tree. All my other settings I have managed to move over fine.

So the time has come to update my boilerplate to Tailwind 4, and I can't work out how to transfer my custom variant setup. In my Tailwind 3 tailwind.config.js I have this:

plugins: [
    plugin(function({ addVariant }) {
      addVariant('js', '.js &')
      addVariant('no-js', '.no-js &')
    })
  ],

To add a couple of variants. I think I need to use the new @custom-variant in my styles.css file but I can't work out the syntax. Or I may be barking up the wrong tree. All my other settings I have managed to move over fine.

Share Improve this question asked Mar 20 at 20:50 Mike HarrisonMike Harrison 7882 gold badges16 silver badges45 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

The equivalent for those custom variants would be:

@custom-variant js (.js &);
@custom-variant no-js (.no-js &);

The first token is the name of the variant. The second parameter is the selector modifier.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744384821a4571610.html

相关推荐

  • css - Adding custom variants to TailwindCSS 4 - Stack Overflow

    So the time has come to update my boilerplate to Tailwind 4, and I can't work out how to transfer

    7天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信