diff --git a/CHANGELOG.md b/CHANGELOG.md index d6c7ccb53b29..89d86a5f33b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,14 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Changed +### Added -- Inline `@import` rules in `tailwindcss/index.css` at publish time for better performance ([#13233](https://github.com/tailwindlabs/tailwindcss/pull/13233)) +- Add `inherit` as a universal color ([#13258](https://github.com/tailwindlabs/tailwindcss/pull/13258)) ### Fixed - Validate bare values ([#13245](https://github.com/tailwindlabs/tailwindcss/pull/13245)) +### Changed + +- Inline `@import` rules in `tailwindcss/index.css` at publish time for better performance ([#13233](https://github.com/tailwindlabs/tailwindcss/pull/13233)) + ## [4.0.0-alpha.9] - 2024-03-13 ### Added diff --git a/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap b/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap index f4f1ad0bff6d..a9f669162f88 100644 --- a/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap +++ b/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap @@ -256,6 +256,7 @@ exports[`getClassList 1`] = ` "@container-normal", "absolute", "accent-current", + "accent-inherit", "accent-transparent", "align-baseline", "align-bottom", @@ -389,6 +390,7 @@ exports[`getClassList 1`] = ` "bg-gradient-to-tl", "bg-gradient-to-tr", "bg-inherit", + "bg-inherit", "bg-left", "bg-left-bottom", "bg-left-top", @@ -414,6 +416,7 @@ exports[`getClassList 1`] = ` "border", "border-b", "border-b-current", + "border-b-inherit", "border-b-transparent", "border-collapse", "border-current", @@ -422,17 +425,22 @@ exports[`getClassList 1`] = ` "border-double", "border-e", "border-e-current", + "border-e-inherit", "border-e-transparent", "border-hidden", + "border-inherit", "border-l", "border-l-current", + "border-l-inherit", "border-l-transparent", "border-none", "border-r", "border-r-current", + "border-r-inherit", "border-r-transparent", "border-s", "border-s-current", + "border-s-inherit", "border-s-transparent", "border-separate", "border-solid", @@ -450,13 +458,16 @@ exports[`getClassList 1`] = ` "border-spacing-y-4", "border-t", "border-t-current", + "border-t-inherit", "border-t-transparent", "border-transparent", "border-x", "border-x-current", + "border-x-inherit", "border-x-transparent", "border-y", "border-y-current", + "border-y-inherit", "border-y-transparent", "bottom-0.5", "bottom-1", @@ -507,6 +518,7 @@ exports[`getClassList 1`] = ` "caption-bottom", "caption-top", "caret-current", + "caret-inherit", "caret-transparent", "clear-both", "clear-end", @@ -642,6 +654,7 @@ exports[`getClassList 1`] = ` "decoration-dotted", "decoration-double", "decoration-from-font", + "decoration-inherit", "decoration-solid", "decoration-transparent", "decoration-wavy", @@ -658,6 +671,7 @@ exports[`getClassList 1`] = ` "divide-dashed", "divide-dotted", "divide-double", + "divide-inherit", "divide-none", "divide-solid", "divide-transparent", @@ -688,6 +702,7 @@ exports[`getClassList 1`] = ` "end-auto", "end-full", "fill-current", + "fill-inherit", "fill-transparent", "fixed", "flex-auto", @@ -758,6 +773,7 @@ exports[`getClassList 1`] = ` "from-90%", "from-95%", "from-current", + "from-inherit", "from-transparent", "gap-0.5", "gap-1", @@ -858,9 +874,11 @@ exports[`getClassList 1`] = ` "inset-ring-4", "inset-ring-8", "inset-ring-current", + "inset-ring-inherit", "inset-ring-transparent", "inset-shadow", "inset-shadow-current", + "inset-shadow-inherit", "inset-shadow-transparent", "inset-x-0.5", "inset-x-1", @@ -1116,6 +1134,7 @@ exports[`getClassList 1`] = ` "outline-dashed", "outline-dotted", "outline-double", + "outline-inherit", "outline-none", "outline-offset-0", "outline-offset-1", @@ -1184,6 +1203,7 @@ exports[`getClassList 1`] = ` "place-self-start", "place-self-stretch", "placeholder-current", + "placeholder-inherit", "placeholder-transparent", "pointer-events-auto", "pointer-events-none", @@ -1226,6 +1246,7 @@ exports[`getClassList 1`] = ` "ring-4", "ring-8", "ring-current", + "ring-inherit", "ring-inset", "ring-offset-0", "ring-offset-1", @@ -1233,6 +1254,7 @@ exports[`getClassList 1`] = ` "ring-offset-4", "ring-offset-8", "ring-offset-current", + "ring-offset-inherit", "ring-offset-transparent", "ring-transparent", "rotate-0", @@ -1444,6 +1466,7 @@ exports[`getClassList 1`] = ` "sepia-50", "shadow", "shadow-current", + "shadow-inherit", "shadow-transparent", "shrink", "shrink-0", @@ -1512,6 +1535,7 @@ exports[`getClassList 1`] = ` "stroke-2", "stroke-3", "stroke-current", + "stroke-inherit", "stroke-none", "stroke-transparent", "subpixel-antialiased", @@ -1533,6 +1557,7 @@ exports[`getClassList 1`] = ` "text-current", "text-ellipsis", "text-end", + "text-inherit", "text-justify", "text-left", "text-nowrap", @@ -1564,6 +1589,7 @@ exports[`getClassList 1`] = ` "to-90%", "to-95%", "to-current", + "to-inherit", "to-transparent", "top-0.5", "top-1", @@ -1638,6 +1664,7 @@ exports[`getClassList 1`] = ` "via-90%", "via-95%", "via-current", + "via-inherit", "via-none", "via-transparent", "visible", diff --git a/packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap b/packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap index 6e9d6e44a57a..45d5d0c32785 100644 --- a/packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap +++ b/packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap @@ -90,6 +90,10 @@ exports[`border-* 1`] = ` border-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-inherit { + border-color: inherit; +} + .border-red-500 { border-color: #ef4444; } @@ -199,6 +203,10 @@ exports[`border-b-* 1`] = ` border-bottom-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-b-inherit { + border-bottom-color: inherit; +} + .border-b-red-500 { border-bottom-color: #ef4444; } @@ -308,6 +316,10 @@ exports[`border-e-* 1`] = ` border-inline-end-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-e-inherit { + border-inline-end-color: inherit; +} + .border-e-red-500 { border-inline-end-color: #ef4444; } @@ -417,6 +429,10 @@ exports[`border-l-* 1`] = ` border-left-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-l-inherit { + border-left-color: inherit; +} + .border-l-red-500 { border-left-color: #ef4444; } @@ -526,6 +542,10 @@ exports[`border-r-* 1`] = ` border-right-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-r-inherit { + border-right-color: inherit; +} + .border-r-red-500 { border-right-color: #ef4444; } @@ -635,6 +655,10 @@ exports[`border-s-* 1`] = ` border-inline-start-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-s-inherit { + border-inline-start-color: inherit; +} + .border-s-red-500 { border-inline-start-color: #ef4444; } @@ -744,6 +768,10 @@ exports[`border-t-* 1`] = ` border-top-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-t-inherit { + border-top-color: inherit; +} + .border-t-red-500 { border-top-color: #ef4444; } @@ -881,6 +909,11 @@ exports[`border-x-* 1`] = ` border-right-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-x-inherit { + border-left-color: inherit; + border-right-color: inherit; +} + .border-x-red-500 { border-left-color: #ef4444; border-right-color: #ef4444; @@ -1021,6 +1054,11 @@ exports[`border-y-* 1`] = ` border-bottom-color: color-mix(in srgb, currentColor 50%, transparent); } +.border-y-inherit { + border-top-color: inherit; + border-bottom-color: inherit; +} + .border-y-red-500 { border-top-color: #ef4444; border-bottom-color: #ef4444; diff --git a/packages/tailwindcss/src/utilities.test.ts b/packages/tailwindcss/src/utilities.test.ts index 6d1d2874508c..383da727dd60 100644 --- a/packages/tailwindcss/src/utilities.test.ts +++ b/packages/tailwindcss/src/utilities.test.ts @@ -5101,6 +5101,7 @@ test('accent', () => { 'accent-current/50', 'accent-current/[0.5]', 'accent-current/[50%]', + 'accent-inherit', 'accent-transparent', 'accent-[#0088cc]', 'accent-[#0088cc]/50', @@ -5129,6 +5130,10 @@ test('accent', () => { accent-color: color-mix(in srgb, currentColor 50%, transparent); } + .accent-inherit { + accent-color: inherit; + } + .accent-red-500 { accent-color: #ef4444; } @@ -5152,6 +5157,7 @@ test('accent', () => { '-accent-current/50', '-accent-current/[0.5]', '-accent-current/[50%]', + '-accent-inherit', '-accent-transparent', '-accent-[#0088cc]', '-accent-[#0088cc]/50', @@ -5179,6 +5185,7 @@ test('caret', () => { 'caret-current/50', 'caret-current/[0.5]', 'caret-current/[50%]', + 'caret-inherit', 'caret-transparent', 'caret-[#0088cc]', 'caret-[#0088cc]/50', @@ -5207,6 +5214,10 @@ test('caret', () => { caret-color: color-mix(in srgb, currentColor 50%, transparent); } + .caret-inherit { + caret-color: inherit; + } + .caret-red-500 { caret-color: #ef4444; } @@ -5230,6 +5241,7 @@ test('caret', () => { '-caret-current/50', '-caret-current/[0.5]', '-caret-current/[50%]', + '-caret-inherit', '-caret-transparent', '-caret-[#0088cc]', '-caret-[#0088cc]/50', @@ -5257,6 +5269,7 @@ test('divide-color', () => { 'divide-current/50', 'divide-current/[0.5]', 'divide-current/[50%]', + 'divide-inherit', 'divide-transparent', 'divide-[#0088cc]', 'divide-[#0088cc]/50', @@ -5301,6 +5314,10 @@ test('divide-color', () => { border-color: color-mix(in srgb, currentColor 50%, transparent); } + :where(.divide-inherit > :not([hidden]) ~ :not([hidden])) { + border-color: inherit; + } + :where(.divide-red-500 > :not([hidden]) ~ :not([hidden])) { border-color: #ef4444; } @@ -5332,6 +5349,7 @@ test('divide-color', () => { '-divide-current/50', '-divide-current/[0.5]', '-divide-current/[50%]', + '-divide-inherit', '-divide-transparent', '-divide-[#0088cc]', '-divide-[#0088cc]/50', @@ -6673,6 +6691,7 @@ for (let prefix of prefixes) { classes.push(`${prefix}-[#0088cc]/50`) classes.push(`${prefix}-current`) classes.push(`${prefix}-current/50`) + classes.push(`${prefix}-inherit`) classes.push(`${prefix}-transparent`) // Inference: Color @@ -6741,7 +6760,6 @@ test('bg', () => { `, [ // background-color - 'bg-inherit', 'bg-red-500', 'bg-red-500/50', 'bg-red-500/[0.5]', @@ -6750,6 +6768,7 @@ test('bg', () => { 'bg-current/50', 'bg-current/[0.5]', 'bg-current/[50%]', + 'bg-inherit', 'bg-transparent', 'bg-[#0088cc]', 'bg-[#0088cc]/50', @@ -7034,7 +7053,6 @@ test('bg', () => { 'bg-unknown', // background-color - '-bg-inherit', '-bg-red-500', '-bg-red-500/50', '-bg-red-500/[0.5]', @@ -7043,6 +7061,7 @@ test('bg', () => { '-bg-current/50', '-bg-current/[0.5]', '-bg-current/[50%]', + '-bg-inherit', '-bg-transparent', '-bg-[#0088cc]', '-bg-[#0088cc]/50', @@ -7129,6 +7148,7 @@ test('from', () => { 'from-current/50', 'from-current/[0.5]', 'from-current/[50%]', + 'from-inherit', 'from-transparent', 'from-[#0088cc]', 'from-[#0088cc]/50', @@ -7198,6 +7218,11 @@ test('from', () => { --tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position)); } + .from-inherit { + --tw-gradient-from: inherit; + --tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position)); + } + .from-red-500 { --tw-gradient-from: #ef4444; --tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position)); @@ -7299,6 +7324,7 @@ test('from', () => { '-from-current/50', '-from-current/[0.5]', '-from-current/[50%]', + '-from-inherit', '-from-transparent', '-from-[#0088cc]', '-from-[#0088cc]/50', @@ -7332,6 +7358,7 @@ test('via', () => { 'via-current/50', 'via-current/[0.5]', 'via-current/[50%]', + 'via-inherit', 'via-transparent', 'via-[#0088cc]', 'via-[#0088cc]/50', @@ -7409,6 +7436,12 @@ test('via', () => { --tw-gradient-stops: var(--tw-gradient-via-stops); } + .via-inherit { + --tw-gradient-via: inherit; + --tw-gradient-via-stops: var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position); + --tw-gradient-stops: var(--tw-gradient-via-stops); + } + .via-red-500 { --tw-gradient-via: #ef4444; --tw-gradient-via-stops: var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position); @@ -7513,6 +7546,7 @@ test('via', () => { '-via-current/50', '-via-current/[0.5]', '-via-current/[50%]', + '-via-inherit', '-via-transparent', '-via-[#0088cc]', '-via-[#0088cc]/50', @@ -7546,6 +7580,7 @@ test('to', () => { 'to-current/50', 'to-current/[0.5]', 'to-current/[50%]', + 'to-inherit', 'to-transparent', 'to-[#0088cc]', 'to-[#0088cc]/50', @@ -7615,6 +7650,11 @@ test('to', () => { --tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position)); } + .to-inherit { + --tw-gradient-to: inherit; + --tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position)); + } + .to-red-500 { --tw-gradient-to: #ef4444; --tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position)); @@ -7716,6 +7756,7 @@ test('to', () => { '-to-current/50', '-to-current/[0.5]', '-to-current/[50%]', + '-to-inherit', '-to-transparent', '-to-[#0088cc]', '-to-[#0088cc]/50', @@ -8036,6 +8077,7 @@ test('fill', () => { 'fill-current/50', 'fill-current/[0.5]', 'fill-current/[50%]', + 'fill-inherit', 'fill-transparent', 'fill-[#0088cc]', 'fill-[#0088cc]/50', @@ -8064,6 +8106,10 @@ test('fill', () => { fill: color-mix(in srgb, currentColor 50%, transparent); } + .fill-inherit { + fill: inherit; + } + .fill-red-500 { fill: #ef4444; } @@ -8088,6 +8134,7 @@ test('fill', () => { '-fill-current/50', '-fill-current/[0.5]', '-fill-current/[50%]', + '-fill-inherit', '-fill-transparent', '-fill-[#0088cc]', '-fill-[#0088cc]/50', @@ -8116,6 +8163,7 @@ test('stroke', () => { 'stroke-current/50', 'stroke-current/[0.5]', 'stroke-current/[50%]', + 'stroke-inherit', 'stroke-transparent', 'stroke-[#0088cc]', 'stroke-[#0088cc]/50', @@ -8180,6 +8228,10 @@ test('stroke', () => { stroke: color-mix(in srgb, currentColor 50%, transparent); } + .stroke-inherit { + stroke: inherit; + } + .stroke-none { stroke: none; } @@ -8238,6 +8290,7 @@ test('stroke', () => { '-stroke-current/50', '-stroke-current/[0.5]', '-stroke-current/[50%]', + '-stroke-inherit', '-stroke-transparent', '-stroke-[#0088cc]', '-stroke-[#0088cc]/50', @@ -8883,6 +8936,7 @@ test('placeholder', () => { 'placeholder-current/50', 'placeholder-current/[0.5]', 'placeholder-current/[50%]', + 'placeholder-inherit', 'placeholder-transparent', 'placeholder-[#0088cc]', 'placeholder-[#0088cc]/50', @@ -8927,6 +8981,10 @@ test('placeholder', () => { color: color-mix(in srgb, currentColor 50%, transparent); } + .placeholder-inherit::placeholder { + color: inherit; + } + .placeholder-red-500::placeholder { color: #ef4444; } @@ -8958,6 +9016,7 @@ test('placeholder', () => { '-placeholder-current/50', '-placeholder-current/[0.5]', '-placeholder-current/[50%]', + '-placeholder-inherit', '-placeholder-transparent', '-placeholder-[#0088cc]', '-placeholder-[#0088cc]/50', @@ -8986,6 +9045,7 @@ test('decoration', () => { 'decoration-current/50', 'decoration-current/[0.5]', 'decoration-current/[50%]', + 'decoration-inherit', 'decoration-transparent', 'decoration-[#0088cc]', 'decoration-[#0088cc]/50', @@ -9063,6 +9123,11 @@ test('decoration', () => { text-decoration-color: color-mix(in srgb, currentColor 50%, transparent); } + .decoration-inherit { + -webkit-text-decoration-color: inherit; + text-decoration-color: inherit; + } + .decoration-red-500 { text-decoration-color: #ef4444; } @@ -10296,6 +10361,7 @@ test('outline', () => { 'outline-current/50', 'outline-current/[0.5]', 'outline-current/[50%]', + 'outline-inherit', 'outline-transparent', 'outline-[#0088cc]', 'outline-[#0088cc]/50', @@ -10404,6 +10470,10 @@ test('outline', () => { outline-color: color-mix(in srgb, currentColor 50%, transparent); } + .outline-inherit { + outline-color: inherit; + } + .outline-red-500 { outline-color: #ef4444; } @@ -10461,6 +10531,7 @@ test('outline', () => { '-outline-current/50', '-outline-current/[0.5]', '-outline-current/[50%]', + '-outline-inherit', '-outline-transparent', '-outline-[#0088cc]', '-outline-[#0088cc]/50', @@ -10590,6 +10661,7 @@ test('text', () => { 'text-current/50', 'text-current/[0.5]', 'text-current/[50%]', + 'text-inherit', 'text-transparent', 'text-[#0088cc]', 'text-[#0088cc]/50', @@ -10739,6 +10811,10 @@ test('text', () => { color: color-mix(in srgb, currentColor 50%, transparent); } + .text-inherit { + color: inherit; + } + .text-red-500 { color: #ef4444; } @@ -10763,6 +10839,7 @@ test('text', () => { '-text-current/50', '-text-current/[0.5]', '-text-current/[50%]', + '-text-inherit', '-text-transparent', '-text-[#0088cc]', '-text-[#0088cc]/50', @@ -10807,6 +10884,7 @@ test('shadow', () => { 'shadow-current/50', 'shadow-current/[0.5]', 'shadow-current/[50%]', + 'shadow-inherit', 'shadow-transparent', 'shadow-[#0088cc]', 'shadow-[#0088cc]/50', @@ -10897,6 +10975,11 @@ test('shadow', () => { --tw-shadow: var(--tw-shadow-colored); } + .shadow-inherit { + --tw-shadow-color: inherit; + --tw-shadow: var(--tw-shadow-colored); + } + .shadow-red-500 { --tw-shadow-color: #ef4444; --tw-shadow: var(--tw-shadow-colored); @@ -10993,6 +11076,7 @@ test('shadow', () => { '-shadow-current/50', '-shadow-current/[0.5]', '-shadow-current/[50%]', + '-shadow-inherit', '-shadow-transparent', '-shadow-[#0088cc]', '-shadow-[#0088cc]/50', @@ -11033,6 +11117,7 @@ test('inset-shadow', () => { 'inset-shadow-current/50', 'inset-shadow-current/[0.5]', 'inset-shadow-current/[50%]', + 'inset-shadow-inherit', 'inset-shadow-transparent', 'inset-shadow-[#0088cc]', 'inset-shadow-[#0088cc]/50', @@ -11123,6 +11208,11 @@ test('inset-shadow', () => { --tw-inset-shadow: var(--tw-inset-shadow-colored); } + .inset-shadow-inherit { + --tw-inset-shadow-color: inherit; + --tw-inset-shadow: var(--tw-inset-shadow-colored); + } + .inset-shadow-red-500 { --tw-inset-shadow-color: #ef4444; --tw-inset-shadow: var(--tw-inset-shadow-colored); @@ -11219,6 +11309,7 @@ test('inset-shadow', () => { '-inset-shadow-current/50', '-inset-shadow-current/[0.5]', '-inset-shadow-current/[50%]', + '-inset-shadow-inherit', '-inset-shadow-transparent', '-inset-shadow-[#0088cc]', '-inset-shadow-[#0088cc]/50', @@ -11249,6 +11340,7 @@ test('ring', () => { 'ring-current/50', 'ring-current/[0.5]', 'ring-current/[50%]', + 'ring-inherit', 'ring-transparent', 'ring-[#0088cc]', 'ring-[#0088cc]/50', @@ -11345,6 +11437,10 @@ test('ring', () => { --tw-ring-color: color-mix(in srgb, currentColor 50%, transparent); } + .ring-inherit { + --tw-ring-color: inherit; + } + .ring-red-500 { --tw-ring-color: #ef4444; } @@ -11442,6 +11538,7 @@ test('ring', () => { '-ring-current/50', '-ring-current/[0.5]', '-ring-current/[50%]', + '-ring-inherit', '-ring-transparent', '-ring-[#0088cc]', '-ring-[#0088cc]/50', @@ -11477,6 +11574,7 @@ test('inset-ring', () => { 'inset-ring-current/50', 'inset-ring-current/[0.5]', 'inset-ring-current/[50%]', + 'inset-ring-inherit', 'inset-ring-transparent', 'inset-ring-[#0088cc]', 'inset-ring-[#0088cc]/50', @@ -11573,6 +11671,10 @@ test('inset-ring', () => { --tw-inset-ring-color: color-mix(in srgb, currentColor 50%, transparent); } + .inset-ring-inherit { + --tw-inset-ring-color: inherit; + } + .inset-ring-red-500 { --tw-inset-ring-color: #ef4444; } @@ -11665,6 +11767,7 @@ test('inset-ring', () => { '-inset-ring-current/50', '-inset-ring-current/[0.5]', '-inset-ring-current/[50%]', + '-inset-ring-inherit', '-inset-ring-transparent', '-inset-ring-[#0088cc]', '-inset-ring-[#0088cc]/50', @@ -11701,6 +11804,7 @@ test('ring-offset', () => { 'ring-offset-current/50', 'ring-offset-current/[0.5]', 'ring-offset-current/[50%]', + 'ring-offset-inherit', 'ring-offset-transparent', 'ring-offset-[#0088cc]', 'ring-offset-[#0088cc]/50', @@ -11792,6 +11896,10 @@ test('ring-offset', () => { --tw-ring-offset-color: color-mix(in srgb, currentColor 50%, transparent); } + .ring-offset-inherit { + --tw-ring-offset-color: inherit; + } + .ring-offset-red-500 { --tw-ring-offset-color: #ef4444; } @@ -11817,6 +11925,7 @@ test('ring-offset', () => { '-ring-offset-current/50', '-ring-offset-current/[0.5]', '-ring-offset-current/[50%]', + '-ring-offset-inherit', '-ring-offset-transparent', '-ring-offset-[#0088cc]', '-ring-offset-[#0088cc]/50', diff --git a/packages/tailwindcss/src/utilities.ts b/packages/tailwindcss/src/utilities.ts index cbfb73659e60..fb952c1f5199 100644 --- a/packages/tailwindcss/src/utilities.ts +++ b/packages/tailwindcss/src/utilities.ts @@ -176,10 +176,11 @@ function withNegative( } /** - * Finds a color in the theme under one of the given theme keys that matches `candidateValue`. + * Finds a color in the theme under one of the given theme keys that matches + * `candidateValue`. * - * The values `transparent` and `current` are special-cased as they are universal and don't need to - * be resolved from the theme. + * The values `inherit`, `transparent` and `current` are special-cased as they + * are universal and don't need to be resolved from the theme. */ function resolveThemeColor( candidate: Extract, @@ -199,6 +200,10 @@ function resolveThemeColor( let value: string | null = null switch (candidate.value!.value) { + case 'inherit': { + value = 'inherit' + break + } case 'transparent': { value = 'transparent' break @@ -385,7 +390,7 @@ export function createUtilities(theme: Theme) { suggest(classRoot, () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: desc.themeKeys, modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -2154,7 +2159,7 @@ export function createUtilities(theme: Theme) { suggest(classRoot, () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--border-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -2432,7 +2437,7 @@ export function createUtilities(theme: Theme) { suggest('bg', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--background-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -2511,7 +2516,7 @@ export function createUtilities(theme: Theme) { suggest(classRoot, () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--background-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -2628,7 +2633,7 @@ export function createUtilities(theme: Theme) { suggest('fill', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--fill', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -2679,7 +2684,7 @@ export function createUtilities(theme: Theme) { suggest('stroke', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--stroke', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -2981,7 +2986,7 @@ export function createUtilities(theme: Theme) { suggest('decoration', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--text-decoration-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -3806,7 +3811,7 @@ export function createUtilities(theme: Theme) { suggest('outline', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--outline-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -3953,7 +3958,7 @@ export function createUtilities(theme: Theme) { suggest('text', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--text-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -4074,7 +4079,7 @@ export function createUtilities(theme: Theme) { suggest('shadow', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--box-shadow-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -4174,7 +4179,7 @@ export function createUtilities(theme: Theme) { suggest('inset-shadow', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--box-shadow-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -4251,7 +4256,7 @@ export function createUtilities(theme: Theme) { suggest('ring', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--ring-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -4324,7 +4329,7 @@ export function createUtilities(theme: Theme) { suggest('inset-ring', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--ring-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'], @@ -4389,7 +4394,7 @@ export function createUtilities(theme: Theme) { suggest('ring-offset', () => [ { - values: ['current', 'transparent'], + values: ['current', 'inherit', 'transparent'], valueThemeKeys: ['--ring-offset-color', '--color'], modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), modifierThemeKeys: ['--opacity'],