Skip to content

Document new @variant behavior where you can stack & compounds variants#2481

Open
RobinMalfait wants to merge 2 commits into4.3.0from
feat/document-compound-and-stacked-variants-in-at-variant
Open

Document new @variant behavior where you can stack & compounds variants#2481
RobinMalfait wants to merge 2 commits into4.3.0from
feat/document-compound-and-stacked-variants-in-at-variant

Conversation

@RobinMalfait
Copy link
Copy Markdown
Member

@RobinMalfait RobinMalfait commented May 4, 2026

Direct link: https://tailwindcss-com-git-feat-document-compound-9d8eca-tailwindlabs.vercel.app/docs/adding-custom-styles#using-variants

This PR documents the new @variant behavior that was introduced in tailwindlabs/tailwindcss#19996 where you can stack variants (like you would in normal HTML):

.my-element {
  background: white;
  @variant hover:focus {
    background: black;
  }
}

Which compiles to:

.my-element {
  background: white;

  &:hover {
    @media (hover: hover) {
      &:focus {
        background: black;
      }
    }
  }
}

Similarly, this adds docs for compound variants, where you can define the same CSS in different situations:

.my-element {
  background: white;
  @variant hover, focus {
    background: black;
  }
}

Which compiles to:

.my-element {
  background: white;
  &:hover {
    @media (hover: hover) {
      background: black;
    }
  }

  &:focus {
    background: black;
  }
}
image

@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tailwindcss-com Ready Ready Preview, Comment May 8, 2026 2:08pm

Request Review

@RobinMalfait RobinMalfait force-pushed the feat/document-compound-and-stacked-variants-in-at-variant branch from a6040fa to fc3b77d Compare May 4, 2026 19:30
@RobinMalfait RobinMalfait changed the base branch from main to 4.3.0 May 7, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant