Skip to content

Commit 3821f69

Browse files
authored
Add new ** variant (#14903)
This PR adds a new `**` variant to target any level of children. This is very similar to the `*` variant, the big difference is that: - `*` applies to direct children only - `**` applies to any level of children Thought of this because of all the recent work we did around globs. So a good analogy for this is glob syntax where you have the exact same difference. `*.html` vs `**/*.html`.
1 parent a4f8a36 commit 3821f69

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Support derived spacing scales based on a single `--spacing` theme value ([#14857](https://github.com/tailwindlabs/tailwindcss/pull/14857))
1313
- Add `svh`, `dvh`, `svw`, `dvw`, and `auto` values to all width/height/size utilities ([#14857](https://github.com/tailwindlabs/tailwindcss/pull/14857))
14+
- Add new `**` variant ([#14903](https://github.com/tailwindlabs/tailwindcss/pull/14903))
1415
- _Upgrade (experimental)_: Migrate `grid-cols-[subgrid]` and `grid-rows-[subgrid]` to `grid-cols-subgrid` and `grid-rows-subgrid` ([#14840](https://github.com/tailwindlabs/tailwindcss/pull/14840))
1516
- _Upgrade (experimental)_: Support migrating projects with multiple config files ([#14863](https://github.com/tailwindlabs/tailwindcss/pull/14863))
1617
- _Upgrade (experimental)_: Rename `shadow` to `shadow-sm`, `shadow-sm` to `shadow-xs`, and `shadow-xs` to `shadow-2xs` ([#14875](https://github.com/tailwindlabs/tailwindcss/pull/14875))

integrations/cli/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe.each([
4444
`,
4545
'project-a/index.html': html`
4646
<div
47-
class="underline 2xl:font-bold hocus:underline inverted:flex"
47+
class="underline 2xl:font-bold hocus:underline inverted:flex *:flex **:flex"
4848
></div>
4949
`,
5050
'project-a/plugin.js': js`
@@ -89,6 +89,8 @@ describe.each([
8989
candidate`content-['project-b/src/index.js']`,
9090
candidate`inverted:flex`,
9191
candidate`hocus:underline`,
92+
candidate`*:flex`,
93+
candidate`**:flex`,
9294
])
9395
},
9496
)

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6950,6 +6950,13 @@ exports[`getVariants 1`] = `
69506950
"selectors": [Function],
69516951
"values": [],
69526952
},
6953+
{
6954+
"hasDash": true,
6955+
"isArbitrary": false,
6956+
"name": "**",
6957+
"selectors": [Function],
6958+
"values": [],
6959+
},
69536960
{
69546961
"hasDash": true,
69556962
"isArbitrary": true,

packages/tailwindcss/src/variants.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ test('*', async () => {
2424
expect(await run(['*/foo:flex'])).toEqual('')
2525
})
2626

27+
test('**', async () => {
28+
expect(await run(['**:flex'])).toMatchInlineSnapshot(`
29+
":where(.\\*\\*\\:flex *) {
30+
display: flex;
31+
}"
32+
`)
33+
expect(await run(['**/foo:flex'])).toEqual('')
34+
})
35+
2736
test('first-letter', async () => {
2837
expect(await run(['first-letter:flex'])).toMatchInlineSnapshot(`
2938
".first-letter\\:flex:first-letter {

packages/tailwindcss/src/variants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ export function createVariants(theme: Theme): Variants {
364364

365365
variants.static('force', () => {}, { compounds: Compounds.Never })
366366
staticVariant('*', [':where(& > *)'], { compounds: Compounds.Never })
367+
staticVariant('**', [':where(& *)'], { compounds: Compounds.Never })
367368

368369
function negateConditions(ruleName: string, conditions: string[]) {
369370
return conditions.map((condition) => {

0 commit comments

Comments
 (0)