Skip to content

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

Merged
RobinMalfait merged 2 commits into
4.3.0from
feat/document-compound-and-stacked-variants-in-at-variant
May 11, 2026
Merged

Document new @variant behavior where you can stack & compounds variants#2481
RobinMalfait merged 2 commits into
4.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 9:20pm

Request Review

@RobinMalfait RobinMalfait force-pushed the feat/document-compound-and-stacked-variants-in-at-variant branch from 097ad61 to 9395d8e Compare May 8, 2026 21:18
@RobinMalfait RobinMalfait merged commit 1235b40 into 4.3.0 May 11, 2026
2 checks passed
@RobinMalfait RobinMalfait deleted the feat/document-compound-and-stacked-variants-in-at-variant branch May 11, 2026 09:33
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