Skip to content

Commit 91c0d56

Browse files
committed
Revert "Temporarily revert changes to `@utility"
This reverts commit 1aab04c.
1 parent 498b06f commit 91c0d56

File tree

4 files changed

+228
-69
lines changed

4 files changed

+228
-69
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- _Experimental_: Add `user-valid` and `user-invalid` variants ([#12370](https://github.com/tailwindlabs/tailwindcss/pull/12370))
2020
- _Experimental_: Add `wrap-anywhere`, `wrap-break-word`, and `wrap-normal` utilities ([#12128](https://github.com/tailwindlabs/tailwindcss/pull/12128))
2121
- _Experimental_: Add `@source inline(…)` ([#17147](https://github.com/tailwindlabs/tailwindcss/pull/17147))
22+
- Add support for literal values in `--value('…')` and `--modifier('…')` ([#17304](https://github.com/tailwindlabs/tailwindcss/pull/17304))
23+
- Add suggestions when `--spacing(--value(integer, number))` is used ([#17308](https://github.com/tailwindlabs/tailwindcss/pull/17308))
2224

2325
### [4.0.15] - 2025-03-20
2426

packages/tailwindcss/src/intellisense.test.ts

+38-3
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,31 @@ test('Custom functional @utility', async () => {
476476
477477
--leading-foo: 1.5;
478478
--leading-bar: 2;
479+
480+
--spacing: 0.25rem;
481+
--spacing-custom: 123px;
479482
}
480483
481484
@utility tab-* {
482-
tab-size: --value(--tab-size);
485+
tab-size: --value(--tab-size, 'revert', 'initial');
483486
}
484487
485488
@utility example-* {
486489
font-size: --value(--text);
487490
line-height: --value(--text- * --line-height);
488-
line-height: --modifier(--leading);
491+
line-height: --modifier(--leading, 'normal');
492+
}
493+
494+
@utility with-custom-spacing-* {
495+
size: --value(--spacing);
496+
}
497+
498+
@utility with-integer-spacing-* {
499+
size: --spacing(--value(integer));
500+
}
501+
502+
@utility with-number-spacing-* {
503+
size: --spacing(--value(number));
489504
}
490505
491506
@utility -negative-* {
@@ -507,12 +522,32 @@ test('Custom functional @utility', async () => {
507522
expect(classNames).toContain('tab-2')
508523
expect(classNames).toContain('tab-4')
509524
expect(classNames).toContain('tab-github')
525+
expect(classNames).toContain('tab-revert')
526+
expect(classNames).toContain('tab-initial')
510527

511528
expect(classNames).not.toContain('-tab-1')
512529
expect(classNames).not.toContain('-tab-2')
513530
expect(classNames).not.toContain('-tab-4')
514531
expect(classNames).not.toContain('-tab-github')
515532

533+
expect(classNames).toContain('with-custom-spacing-custom')
534+
expect(classNames).not.toContain('with-custom-spacing-0')
535+
expect(classNames).not.toContain('with-custom-spacing-0.5')
536+
expect(classNames).not.toContain('with-custom-spacing-1')
537+
expect(classNames).not.toContain('with-custom-spacing-1.5')
538+
539+
expect(classNames).not.toContain('with-integer-spacing-custom')
540+
expect(classNames).toContain('with-integer-spacing-0')
541+
expect(classNames).not.toContain('with-integer-spacing-0.5')
542+
expect(classNames).toContain('with-integer-spacing-1')
543+
expect(classNames).not.toContain('with-integer-spacing-1.5')
544+
545+
expect(classNames).not.toContain('with-number-spacing-custom')
546+
expect(classNames).toContain('with-number-spacing-0')
547+
expect(classNames).toContain('with-number-spacing-0.5')
548+
expect(classNames).toContain('with-number-spacing-1')
549+
expect(classNames).toContain('with-number-spacing-1.5')
550+
516551
expect(classNames).toContain('-negative-1')
517552
expect(classNames).toContain('-negative-2')
518553
expect(classNames).toContain('-negative-4')
@@ -524,7 +559,7 @@ test('Custom functional @utility', async () => {
524559
expect(classNames).not.toContain('--negative-github')
525560

526561
expect(classNames).toContain('example-xs')
527-
expect(classMap.get('example-xs')?.modifiers).toEqual(['foo', 'bar'])
562+
expect(classMap.get('example-xs')?.modifiers).toEqual(['normal', 'foo', 'bar'])
528563
})
529564

530565
test('Theme keys with underscores are suggested with underscores', async () => {

packages/tailwindcss/src/utilities.test.ts

+36-1
Original file line numberDiff line numberDiff line change
@@ -17256,6 +17256,23 @@ describe('custom utilities', () => {
1725617256
expect(await compileCss(input, ['tab-foo'])).toEqual('')
1725717257
})
1725817258

17259+
test('resolve literal values', async () => {
17260+
let input = css`
17261+
@utility tab-* {
17262+
tab-size: --value('revert');
17263+
}
17264+
17265+
@tailwind utilities;
17266+
`
17267+
17268+
expect(await compileCss(input, ['tab-revert'])).toMatchInlineSnapshot(`
17269+
".tab-revert {
17270+
tab-size: revert;
17271+
}"
17272+
`)
17273+
expect(await compileCss(input, ['tab-initial'])).toEqual('')
17274+
})
17275+
1725917276
test('resolving bare values with constraints for integer, percentage, and ratio', async () => {
1726017277
let input = css`
1726117278
@utility example-* {
@@ -17720,6 +17737,7 @@ describe('custom utilities', () => {
1772017737
--value: --value(--value, [length]);
1772117738
--modifier: --modifier(--modifier, [length]);
1772217739
--modifier-with-calc: calc(--modifier(--modifier, [length]) * 2);
17740+
--modifier-literals: --modifier('literal', 'literal-2');
1772317741
}
1772417742
1772517743
@tailwind utilities;
@@ -17731,6 +17749,8 @@ describe('custom utilities', () => {
1773117749
'example-sm/7',
1773217750
'example-[12px]',
1773317751
'example-[12px]/[16px]',
17752+
'example-sm/literal',
17753+
'example-sm/literal-2',
1773417754
]),
1773517755
).toMatchInlineSnapshot(`
1773617756
".example-\\[12px\\]\\/\\[16px\\] {
@@ -17745,6 +17765,16 @@ describe('custom utilities', () => {
1774517765
--modifier-with-calc: calc(var(--modifier-7, 28px) * 2);
1774617766
}
1774717767
17768+
.example-sm\\/literal {
17769+
--value: var(--value-sm, 14px);
17770+
--modifier-literals: literal;
17771+
}
17772+
17773+
.example-sm\\/literal-2 {
17774+
--value: var(--value-sm, 14px);
17775+
--modifier-literals: literal-2;
17776+
}
17777+
1774817778
.example-\\[12px\\] {
1774917779
--value: 12px;
1775017780
}
@@ -17754,7 +17784,12 @@ describe('custom utilities', () => {
1775417784
}"
1775517785
`)
1775617786
expect(
17757-
await compileCss(input, ['example-foo', 'example-foo/[12px]', 'example-foo/12']),
17787+
await compileCss(input, [
17788+
'example-foo',
17789+
'example-foo/[12px]',
17790+
'example-foo/12',
17791+
'example-sm/unknown-literal',
17792+
]),
1775817793
).toEqual('')
1775917794
})
1776017795

0 commit comments

Comments
 (0)