Skip to content

Commit 124b82b

Browse files
Add details-content variant (tailwindlabs#15319)
This matches the new `::details-content` pseudo element. See https://developer.chrome.com/blog/styling-details#the_details-content_pseudo for more info. Currently shipped in Chromium, in development in WebKit and no development yet in Firefox but they're [supportive](mozilla/standards-positions#1027). --------- Co-authored-by: Philipp Spiess <hello@philippspiess.com>
1 parent ab9df29 commit 124b82b

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- _Experimental_: Add `details-content` variant ([#15319](https://github.com/tailwindlabs/tailwindcss/pull/15319))
1213
- _Experimental_: Add `inverted-colors` variant ([#11693](https://github.com/tailwindlabs/tailwindcss/pull/11693))
1314
- _Experimental_: Add `user-valid` and `user-invalid` variants ([#12370](https://github.com/tailwindlabs/tailwindcss/pull/12370))
1415
- _Experimental_: Add `wrap-anywhere`, `wrap-break-word`, and `wrap-normal` utilities ([#12128](https://github.com/tailwindlabs/tailwindcss/pull/12128))

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

+7
Original file line numberDiff line numberDiff line change
@@ -8610,6 +8610,13 @@ exports[`getVariants 1`] = `
86108610
"selectors": [Function],
86118611
"values": [],
86128612
},
8613+
{
8614+
"hasDash": true,
8615+
"isArbitrary": false,
8616+
"name": "details-content",
8617+
"selectors": [Function],
8618+
"values": [],
8619+
},
86138620
{
86148621
"hasDash": true,
86158622
"isArbitrary": false,
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export const enableDetailsContent = process.env.FEATURES_ENV !== 'stable'
12
export const enableInvertedColors = process.env.FEATURES_ENV !== 'stable'
23
export const enableUserValid = process.env.FEATURES_ENV !== 'stable'
34
export const enableWrapAnywhere = process.env.FEATURES_ENV !== 'stable'

packages/tailwindcss/src/variants.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ test('backdrop', async () => {
9595
expect(await run(['backdrop/foo:flex'])).toEqual('')
9696
})
9797

98+
test('details-content', async () => {
99+
expect(await run(['details-content:flex'])).toMatchInlineSnapshot(`
100+
".details-content\\:flex::details-content {
101+
display: flex;
102+
}"
103+
`)
104+
expect(await run(['details-content/foo:flex'])).toEqual('')
105+
})
106+
98107
test('before', async () => {
99108
expect(await run(['before:flex'])).toMatchInlineSnapshot(`
100109
".before\\:flex:before {
@@ -2092,6 +2101,7 @@ test('variant order', async () => {
20922101
'data-custom:flex',
20932102
'data-[custom=true]:flex',
20942103
'default:flex',
2104+
'details-content:flex',
20952105
'disabled:flex',
20962106
'empty:flex',
20972107
'enabled:flex',
@@ -2178,6 +2188,10 @@ test('variant order', async () => {
21782188
display: flex;
21792189
}
21802190
2191+
.details-content\\:flex::details-content {
2192+
display: flex;
2193+
}
2194+
21812195
.before\\:flex:before, .after\\:flex:after {
21822196
content: var(--tw-content);
21832197
display: flex;

packages/tailwindcss/src/variants.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type StyleRule,
1313
} from './ast'
1414
import { type Variant } from './candidate'
15-
import { enableInvertedColors, enableUserValid } from './feature-flags'
15+
import { enableDetailsContent, enableInvertedColors, enableUserValid } from './feature-flags'
1616
import type { Theme } from './theme'
1717
import { compareBreakpoints } from './utils/compare-breakpoints'
1818
import { DefaultMap } from './utils/default-map'
@@ -628,6 +628,9 @@ export function createVariants(theme: Theme): Variants {
628628
staticVariant('file', ['&::file-selector-button'])
629629
staticVariant('placeholder', ['&::placeholder'])
630630
staticVariant('backdrop', ['&::backdrop'])
631+
if (enableDetailsContent) {
632+
staticVariant('details-content', ['&::details-content'])
633+
}
631634

632635
{
633636
function contentProperties() {

0 commit comments

Comments
 (0)