From 13db1adcb846fe192dd0e50eefe64bdc46114122 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 28 Apr 2025 19:17:09 +0200 Subject: [PATCH 1/3] add failing test --- packages/tailwindcss/src/utilities.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/tailwindcss/src/utilities.test.ts b/packages/tailwindcss/src/utilities.test.ts index 1b7cf00edd16..419e6373a27d 100644 --- a/packages/tailwindcss/src/utilities.test.ts +++ b/packages/tailwindcss/src/utilities.test.ts @@ -10695,6 +10695,8 @@ test('bg', async () => { 'bg-red-500/2.75', 'bg-red-500/[0.5]', 'bg-red-500/[50%]', + 'bg-red-500/100', + 'bg-red-500/[100%]', 'bg-blue-500', 'bg-current', 'bg-current/50', @@ -10992,6 +10994,10 @@ test('bg', async () => { } } + .bg-red-500\\/100 { + background-color: var(--color-red-500); + } + .bg-red-500\\/\\[0\\.5\\] { background-color: #ef444480; } @@ -11012,6 +11018,10 @@ test('bg', async () => { } } + .bg-red-500\\/\\[100\\%\\] { + background-color: var(--color-red-500); + } + .bg-transparent { background-color: #0000; } From cd452e3993fc3fc500cf9afe35132737c79285e7 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Sun, 27 Apr 2025 12:23:51 +0200 Subject: [PATCH 2/3] alpha of 100% is the default --- packages/tailwindcss/src/utilities.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/tailwindcss/src/utilities.ts b/packages/tailwindcss/src/utilities.ts index 40050cfd2ab1..3c9a189c1af2 100644 --- a/packages/tailwindcss/src/utilities.ts +++ b/packages/tailwindcss/src/utilities.ts @@ -173,6 +173,11 @@ export function withAlpha(value: string, alpha: string): string { alpha = `${alphaAsNumber * 100}%` } + // No need for `color-mix` if the alpha is `100%` + if (alpha === '100%') { + return value + } + return `color-mix(in oklab, ${value} ${alpha}, transparent)` } From c788f42ca82aa724357604d8fca1beaec667914d Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 28 Apr 2025 19:21:31 +0200 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71822866829c..2bed1490d0fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replace `_` with `.` in theme suggestions for `@utility` if surrounded by digits ([#17743](https://github.com/tailwindlabs/tailwindcss/pull/17743)) - Upgrade: Bump all Tailwind CSS related dependencies during upgrade ([#17763](https://github.com/tailwindlabs/tailwindcss/pull/17763)) - PostCSS: Ensure that errors in stylesheet dependencies are recoverable ([#17754](https://github.com/tailwindlabs/tailwindcss/pull/17754)) +- Skip `color-mix(…)` when opacity is `100%` ([#17815](https://github.com/tailwindlabs/tailwindcss/pull/17815)) ## [4.1.4] - 2025-04-14