diff --git a/CHANGELOG.md b/CHANGELOG.md index b8c3e59ed84e..5760b4a5a30c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Skip candidates with invalid `theme()` calls ([#14437](https://github.com/tailwindlabs/tailwindcss/pull/14437)) - Don't generate `inset-*` utilities for `--inset-shadow-*` and `--inset-ring-*` theme values ([#14447](https://github.com/tailwindlabs/tailwindcss/pull/14447)) - Include `--default-transition-*` variables in `transition-*` utility output ([#14482](https://github.com/tailwindlabs/tailwindcss/pull/14482)) +- Ensure `rtl` and `ltr` variants work with `[dir=auto]` ([#14306](https://github.com/tailwindlabs/tailwindcss/pull/14306)) ### Changed diff --git a/packages/tailwindcss/src/index.test.ts b/packages/tailwindcss/src/index.test.ts index 3693bbb0e878..0f56d3430d3a 100644 --- a/packages/tailwindcss/src/index.test.ts +++ b/packages/tailwindcss/src/index.test.ts @@ -1979,7 +1979,7 @@ describe('plugins', () => { expect(optimizeCss(compiled).trim()).toMatchInlineSnapshot(` "@layer utilities { - .rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) { + .rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) { display: flex; } @@ -2489,7 +2489,7 @@ describe('@variant', () => { ), ).toMatchInlineSnapshot(` "@layer utilities { - .rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) { + .rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) { display: flex; } diff --git a/packages/tailwindcss/src/variants.test.ts b/packages/tailwindcss/src/variants.test.ts index cb67e48d5b4b..e4a1d720d838 100644 --- a/packages/tailwindcss/src/variants.test.ts +++ b/packages/tailwindcss/src/variants.test.ts @@ -928,7 +928,7 @@ test('peer-*', async () => { test('ltr', async () => { expect(await run(['ltr:flex'])).toMatchInlineSnapshot(` - ".ltr\\:flex:where([dir="ltr"], [dir="ltr"] *) { + ".ltr\\:flex:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) { display: flex; }" `) @@ -937,7 +937,7 @@ test('ltr', async () => { test('rtl', async () => { expect(await run(['rtl:flex'])).toMatchInlineSnapshot(` - ".rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) { + ".rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) { display: flex; }" `) @@ -2762,11 +2762,11 @@ test('variant order', async () => { } } - .ltr\\:flex:where([dir="ltr"], [dir="ltr"] *) { + .ltr\\:flex:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) { display: flex; } - .rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) { + .rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) { display: flex; } diff --git a/packages/tailwindcss/src/variants.ts b/packages/tailwindcss/src/variants.ts index aff3754d261f..7dfcc4046bb3 100644 --- a/packages/tailwindcss/src/variants.ts +++ b/packages/tailwindcss/src/variants.ts @@ -901,8 +901,8 @@ export function createVariants(theme: Theme): Variants { staticVariant('portrait', ['@media (orientation: portrait)'], { compounds: false }) staticVariant('landscape', ['@media (orientation: landscape)'], { compounds: false }) - staticVariant('ltr', ['&:where([dir="ltr"], [dir="ltr"] *)']) - staticVariant('rtl', ['&:where([dir="rtl"], [dir="rtl"] *)']) + staticVariant('ltr', ['&:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *)']) + staticVariant('rtl', ['&:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *)']) staticVariant('dark', ['@media (prefers-color-scheme: dark)'], { compounds: false })