Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Don't use color-mix(…) on currentColor (#17247)" and work around Preflight crash #17306

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix incorrect angle in `-bg-conic-*` utilities ([#17174](https://github.com/tailwindlabs/tailwindcss/pull/17174))
- Fix `border-[12px_4px]` being interpreted as a `border-color` instead of a `border-width` ([#17248](https://github.com/tailwindlabs/tailwindcss/pull/17248))
- Use the `oklab(…)` function when applying opacity to `currentColor` to work around a crash in Safari 16.4 and 16.5 ([#17247](https://github.com/tailwindlabs/tailwindcss/pull/17247))
- Work around a crash in Safari 16.4 and 16.5 when using the default Preflight styles ([#17306](https://github.com/tailwindlabs/tailwindcss/pull/17306))
- Pre-process `<template lang="…">` in Vue files ([#17252](https://github.com/tailwindlabs/tailwindcss/pull/17252))
- Ensure that all CSS variables used by preflight are prefixed ([#17036](https://github.com/tailwindlabs/tailwindcss/pull/17036))
- Ensure that all CSS variables used by Preflight are prefixed ([#17036](https://github.com/tailwindlabs/tailwindcss/pull/17036))

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `

::placeholder {
opacity: 1;
color: oklab(from currentColor l a b / 50%);
}

@supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {
::placeholder {
color: color-mix(in oklab, currentColor 50%, transparent);
}
}

textarea {
Expand Down
18 changes: 14 additions & 4 deletions packages/tailwindcss/preflight.css
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,23 @@ textarea,
}

/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to a semi-transparent version of the current text color. We use the `oklab(…)` function to work around an issue in Safari 16.4 and 16.5. (https://github.com/tailwindlabs/tailwindcss/issues/17194)
Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
*/

::placeholder {
opacity: 1; /* 1 */
color: oklab(from currentColor l a b / 50%); /* 2 */
opacity: 1;
}

/*
Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not
crash when using `color-mix(…)` with `currentColor`. (https://github.com/tailwindlabs/tailwindcss/issues/17194)
*/

@supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or
(contain-intrinsic-size: 1px) /* Safari 17+ */ {
::placeholder {
color: color-mix(in oklab, currentColor 50%, transparent);
}
}

/*
Expand Down
7 changes: 6 additions & 1 deletion packages/tailwindcss/src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ exports[`compiling CSS > prefix all CSS variables inside preflight 1`] = `

::placeholder {
opacity: 1;
color: oklab(from currentColor l a b / 50%);
}

@supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {
::placeholder {
color: color-mix(in oklab, currentColor 50%, transparent);
}
}

textarea {
Expand Down
18 changes: 9 additions & 9 deletions packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ exports[`border-* 1`] = `
}

.border-current\\/50 {
border-color: oklab(from currentColor l a b / 50%);
border-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-inherit {
Expand Down Expand Up @@ -246,7 +246,7 @@ exports[`border-b-* 1`] = `
}

.border-b-current\\/50 {
border-bottom-color: oklab(from currentColor l a b / 50%);
border-bottom-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-b-inherit {
Expand Down Expand Up @@ -388,7 +388,7 @@ exports[`border-e-* 1`] = `
}

.border-e-current\\/50 {
border-inline-end-color: oklab(from currentColor l a b / 50%);
border-inline-end-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-e-inherit {
Expand Down Expand Up @@ -530,7 +530,7 @@ exports[`border-l-* 1`] = `
}

.border-l-current\\/50 {
border-left-color: oklab(from currentColor l a b / 50%);
border-left-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-l-inherit {
Expand Down Expand Up @@ -672,7 +672,7 @@ exports[`border-r-* 1`] = `
}

.border-r-current\\/50 {
border-right-color: oklab(from currentColor l a b / 50%);
border-right-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-r-inherit {
Expand Down Expand Up @@ -814,7 +814,7 @@ exports[`border-s-* 1`] = `
}

.border-s-current\\/50 {
border-inline-start-color: oklab(from currentColor l a b / 50%);
border-inline-start-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-s-inherit {
Expand Down Expand Up @@ -956,7 +956,7 @@ exports[`border-t-* 1`] = `
}

.border-t-current\\/50 {
border-top-color: oklab(from currentColor l a b / 50%);
border-top-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-t-inherit {
Expand Down Expand Up @@ -1098,7 +1098,7 @@ exports[`border-x-* 1`] = `
}

.border-x-current\\/50 {
border-inline-color: oklab(from currentColor l a b / 50%);
border-inline-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-x-inherit {
Expand Down Expand Up @@ -1240,7 +1240,7 @@ exports[`border-y-* 1`] = `
}

.border-y-current\\/50 {
border-block-color: oklab(from currentColor l a b / 50%);
border-block-color: color-mix(in oklab, currentColor 50%, transparent);
}

.border-y-inherit {
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/compat/plugin-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3860,7 +3860,7 @@ describe('matchUtilities()', () => {
}

.scrollbar-current\\/45 {
scrollbar-color: oklab(from currentColor l a b / 45%);
scrollbar-color: color-mix(in oklab, currentColor 45%, transparent);
}"
`)
})
Expand Down
46 changes: 23 additions & 23 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8058,7 +8058,7 @@ test('accent', async () => {
}

.accent-current\\/50, .accent-current\\/\\[0\\.5\\], .accent-current\\/\\[50\\%\\] {
accent-color: oklab(from currentColor l a b / 50%);
accent-color: color-mix(in oklab, currentColor 50%, transparent);
}

.accent-inherit {
Expand Down Expand Up @@ -8173,7 +8173,7 @@ test('caret', async () => {
}

.caret-current\\/50, .caret-current\\/\\[0\\.5\\], .caret-current\\/\\[50\\%\\] {
caret-color: oklab(from currentColor l a b / 50%);
caret-color: color-mix(in oklab, currentColor 50%, transparent);
}

.caret-inherit {
Expand Down Expand Up @@ -8286,7 +8286,7 @@ test('divide-color', async () => {
}

:where(.divide-current\\/50 > :not(:last-child)), :where(.divide-current\\/\\[0\\.5\\] > :not(:last-child)), :where(.divide-current\\/\\[50\\%\\] > :not(:last-child)) {
border-color: oklab(from currentColor l a b / 50%);
border-color: color-mix(in oklab, currentColor 50%, transparent);
}

:where(.divide-inherit > :not(:last-child)) {
Expand Down Expand Up @@ -10248,11 +10248,11 @@ test('bg', async () => {
}

.bg-current\\/50, .bg-current\\/\\[0\\.5\\], .bg-current\\/\\[50\\%\\] {
background-color: oklab(from currentColor l a b / 50%);
background-color: color-mix(in oklab, currentColor 50%, transparent);
}

.bg-current\\/\\[var\\(--bg-opacity\\)\\] {
background-color: oklab(from currentColor l a b / var(--bg-opacity));
background-color: color-mix(in oklab, currentColor var(--bg-opacity), transparent);
}

.bg-inherit {
Expand Down Expand Up @@ -10770,11 +10770,11 @@ test('bg', async () => {
),
).toMatchInlineSnapshot(`
".bg-current\\/custom {
background-color: oklab(from currentColor l a b / var(--opacity-custom, var(--custom-opacity)));
background-color: color-mix(in oklab, currentColor var(--opacity-custom, var(--custom-opacity)), transparent);
}

.bg-current\\/half {
background-color: oklab(from currentColor l a b / var(--opacity-half, .5));
background-color: color-mix(in oklab, currentColor var(--opacity-half, .5), transparent);
}

.\\[color\\:red\\]\\/half {
Expand Down Expand Up @@ -10868,7 +10868,7 @@ test('from', async () => {
}

.from-current\\/50, .from-current\\/\\[0\\.5\\], .from-current\\/\\[50\\%\\] {
--tw-gradient-from: oklab(from currentColor l a b / 50%);
--tw-gradient-from: color-mix(in oklab, currentColor 50%, transparent);
--tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position));
}

Expand Down Expand Up @@ -11094,7 +11094,7 @@ test('via', async () => {
}

.via-current\\/50, .via-current\\/\\[0\\.5\\], .via-current\\/\\[50\\%\\] {
--tw-gradient-via: oklab(from currentColor l a b / 50%);
--tw-gradient-via: color-mix(in oklab, currentColor 50%, transparent);
--tw-gradient-via-stops: var(--tw-gradient-position), 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);
}
Expand Down Expand Up @@ -11316,7 +11316,7 @@ test('to', async () => {
}

.to-current\\/50, .to-current\\/\\[0\\.5\\], .to-current\\/\\[50\\%\\] {
--tw-gradient-to: oklab(from currentColor l a b / 50%);
--tw-gradient-to: color-mix(in oklab, currentColor 50%, transparent);
--tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position));
}

Expand Down Expand Up @@ -11843,7 +11843,7 @@ test('fill', async () => {
}

.fill-current\\/50, .fill-current\\/\\[0\\.5\\], .fill-current\\/\\[50\\%\\] {
fill: oklab(from currentColor l a b / 50%);
fill: color-mix(in oklab, currentColor 50%, transparent);
}

.fill-inherit {
Expand Down Expand Up @@ -11980,7 +11980,7 @@ test('stroke', async () => {
}

.stroke-current\\/50, .stroke-current\\/\\[0\\.5\\], .stroke-current\\/\\[50\\%\\] {
stroke: oklab(from currentColor l a b / 50%);
stroke: color-mix(in oklab, currentColor 50%, transparent);
}

.stroke-inherit {
Expand Down Expand Up @@ -12956,7 +12956,7 @@ test('placeholder', async () => {
}

.placeholder-current\\/50::placeholder, .placeholder-current\\/\\[0\\.5\\]::placeholder, .placeholder-current\\/\\[50\\%\\]::placeholder {
color: oklab(from currentColor l a b / 50%);
color: color-mix(in oklab, currentColor 50%, transparent);
}

.placeholder-inherit::placeholder {
Expand Down Expand Up @@ -13105,9 +13105,9 @@ test('decoration', async () => {
}

.decoration-current\\/50, .decoration-current\\/\\[0\\.5\\], .decoration-current\\/\\[50\\%\\] {
-webkit-text-decoration-color: oklab(from currentColor l a b / 50%);
-webkit-text-decoration-color: oklab(from currentColor l a b / 50%);
text-decoration-color: oklab(from currentColor l a b / 50%);
-webkit-text-decoration-color: color-mix(in oklab, currentColor 50%, transparent);
-webkit-text-decoration-color: color-mix(in oklab, currentColor 50%, transparent);
text-decoration-color: color-mix(in oklab, currentColor 50%, transparent);
}

.decoration-inherit {
Expand Down Expand Up @@ -14810,7 +14810,7 @@ test('outline', async () => {
}

.outline-current\\/50, .outline-current\\/\\[0\\.5\\], .outline-current\\/\\[50\\%\\] {
outline-color: oklab(from currentColor l a b / 50%);
outline-color: color-mix(in oklab, currentColor 50%, transparent);
}

.outline-inherit {
Expand Down Expand Up @@ -15260,7 +15260,7 @@ test('text', async () => {
}

.text-current\\/50, .text-current\\/\\[0\\.5\\], .text-current\\/\\[50\\%\\] {
color: oklab(from currentColor l a b / 50%);
color: color-mix(in oklab, currentColor 50%, transparent);
}

.text-inherit {
Expand Down Expand Up @@ -15429,7 +15429,7 @@ test('shadow', async () => {
}

.shadow-current\\/50, .shadow-current\\/\\[0\\.5\\], .shadow-current\\/\\[50\\%\\] {
--tw-shadow-color: oklab(from currentColor l a b / 50%);
--tw-shadow-color: color-mix(in oklab, currentColor 50%, transparent);
}

.shadow-inherit {
Expand Down Expand Up @@ -15651,7 +15651,7 @@ test('inset-shadow', async () => {
}

.inset-shadow-current\\/50, .inset-shadow-current\\/\\[0\\.5\\], .inset-shadow-current\\/\\[50\\%\\] {
--tw-inset-shadow-color: oklab(from currentColor l a b / 50%);
--tw-inset-shadow-color: color-mix(in oklab, currentColor 50%, transparent);
}

.inset-shadow-inherit {
Expand Down Expand Up @@ -15889,7 +15889,7 @@ test('ring', async () => {
}

.ring-current\\/50, .ring-current\\/\\[0\\.5\\], .ring-current\\/\\[50\\%\\] {
--tw-ring-color: oklab(from currentColor l a b / 50%);
--tw-ring-color: color-mix(in oklab, currentColor 50%, transparent);
}

.ring-inherit {
Expand Down Expand Up @@ -16228,7 +16228,7 @@ test('inset-ring', async () => {
}

.inset-ring-current\\/50, .inset-ring-current\\/\\[0\\.5\\], .inset-ring-current\\/\\[50\\%\\] {
--tw-inset-ring-color: oklab(from currentColor l a b / 50%);
--tw-inset-ring-color: color-mix(in oklab, currentColor 50%, transparent);
}

.inset-ring-inherit {
Expand Down Expand Up @@ -16472,7 +16472,7 @@ test('ring-offset', async () => {
}

.ring-offset-current\\/50, .ring-offset-current\\/\\[0\\.5\\], .ring-offset-current\\/\\[50\\%\\] {
--tw-ring-offset-color: oklab(from currentColor l a b / 50%);
--tw-ring-offset-color: color-mix(in oklab, currentColor 50%, transparent);
}

.ring-offset-inherit {
Expand Down
7 changes: 0 additions & 7 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ export function withAlpha(value: string, alpha: string): string {
alpha = `${alphaAsNumber * 100}%`
}

// Use the `oklab(…)` function when applying alpha to `currentColor` to work
// around a crash with Safari 16.4 and 16.5
// https://github.com/tailwindlabs/tailwindcss/issues/17194
if (value === 'currentColor') {
return `oklab(from currentColor l a b / ${alpha})`
}

return `color-mix(in oklab, ${value} ${alpha}, transparent)`
}

Expand Down