Skip to content

@variant is recognized inside addBase, but not inside addUtilities or addComponents #19258

@benface

Description

@benface

What version of Tailwind CSS are you using?

v4.1.16

What build tool (or framework if it abstracts the build tool) are you using?

Vite 7.1.12

What version of Node.js are you using?

v24.10.0

What browser are you using?

N/A

What operating system are you using?

macOS

Reproduction URL code

In a legacy JS plugin:

addBase({
  '.some-selector': {
    '@variant hover': {
      // hover styles, which will actually work because `@variant` will be transformed into a proper selector
    },
  },
})

addUtilities({  // or `addComponents`
  '.some-selector': {
    '@variant hover': {
      // does NOT work; the compiled CSS will contain `@variant hover` instead of a proper selector
    },
  },
})

Describe your issue

See above. Thank you!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions