Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Ensure `.group` and `.peer` are prefixed when using the `prefix(…)` option ([#15174](https://github.com/tailwindlabs/tailwindcss/pull/15174))

## [4.0.0-beta.2] - 2024-11-22

Expand Down
25 changes: 23 additions & 2 deletions packages/tailwindcss/src/prefix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,35 @@ test('utilities must be prefixed', async () => {
let compiler = await compile(input)

// Prefixed utilities are generated
expect(compiler.build(['tw:underline', 'tw:hover:line-through', 'tw:custom']))
.toMatchInlineSnapshot(`
expect(
compiler.build([
'tw:underline',
'tw:hover:line-through',
'tw:custom',
'tw:group-hover:flex',
'tw:peer-hover:flex',
]),
).toMatchInlineSnapshot(`
".tw\\:custom {
color: red;
}
.tw\\:underline {
text-decoration-line: underline;
}
.tw\\:group-hover\\:flex {
&:is(:where(.tw\\:group):hover *) {
@media (hover: hover) {
display: flex;
}
}
}
.tw\\:peer-hover\\:flex {
&:is(:where(.tw\\:peer):hover ~ *) {
@media (hover: hover) {
display: flex;
}
}
}
.tw\\:hover\\:line-through {
&:hover {
@media (hover: hover) {
Expand Down
8 changes: 4 additions & 4 deletions packages/tailwindcss/src/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ export function createVariants(theme: Theme): Variants {
// Name the group by appending the modifier to `group` class itself if
// present.
let variantSelector = variant.modifier
? `:where(.group\\/${variant.modifier.value})`
: ':where(.group)'
? `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}group\\/${variant.modifier.value})`
: `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}group)`

let didApply = false

Expand Down Expand Up @@ -570,8 +570,8 @@ export function createVariants(theme: Theme): Variants {
// Name the peer by appending the modifier to `peer` class itself if
// present.
let variantSelector = variant.modifier
? `:where(.peer\\/${variant.modifier.value})`
: ':where(.peer)'
? `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}peer\\/${variant.modifier.value})`
: `:where(.${theme.prefix ? `${theme.prefix}\\:` : ''}peer)`

let didApply = false

Expand Down