Skip to content

Commit 2fc57c2

Browse files
committed
Read from --content theme namespace for content-* utilities
1 parent 479b725 commit 2fc57c2

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/tailwindcss/src/utilities.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23259,7 +23259,17 @@ test('contain', async () => {
2325923259
})
2326023260

2326123261
test('content', async () => {
23262-
expect(await run(['content-["hello_world"]'])).toMatchInlineSnapshot(`
23262+
expect(
23263+
await compileCss(
23264+
css`
23265+
@theme {
23266+
--content-slash: '/';
23267+
}
23268+
@tailwind utilities;
23269+
`,
23270+
['content-slash', 'content-["hello_world"]'],
23271+
),
23272+
).toMatchInlineSnapshot(`
2326323273
"@layer properties {
2326423274
@supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {
2326523275
*, :before, :after, ::backdrop {
@@ -23268,11 +23278,20 @@ test('content', async () => {
2326823278
}
2326923279
}
2327023280

23281+
:root, :host {
23282+
--content-slash: "/";
23283+
}
23284+
2327123285
.content-\\[\\"hello_world\\"\\] {
2327223286
--tw-content: "hello world";
2327323287
content: var(--tw-content);
2327423288
}
2327523289

23290+
.content-slash {
23291+
--tw-content: var(--content-slash);
23292+
content: var(--tw-content);
23293+
}
23294+
2327623295
@property --tw-content {
2327723296
syntax: "*";
2327823297
inherits: false;

packages/tailwindcss/src/utilities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4688,7 +4688,9 @@ export function createUtilities(theme: Theme) {
46884688
['content', 'none'],
46894689
])
46904690
functionalUtility('content', {
4691-
themeKeys: [],
4691+
// BC: We only read from the `--content` theme key for compatibility reasons. It's recommended
4692+
// to use the utility with arbitrary values instead.
4693+
themeKeys: ['--content'],
46924694
handle: (value) => [
46934695
atRoot([property('--tw-content', '""')]),
46944696
decl('--tw-content', value),

0 commit comments

Comments
 (0)