Skip to content

Commit 8eca822

Browse files
Don't use color-mix(…) on currentColor
1 parent 1a88518 commit 8eca822

File tree

7 files changed

+44
-36
lines changed

7 files changed

+44
-36
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
### Fixed
2222

2323
- Fix incorrect angle in `-bg-conic-*` utilities ([#17174](https://github.com/tailwindlabs/tailwindcss/pull/17174))
24+
- 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))
2425

2526
## [4.0.14] - 2025-03-13
2627

packages/@tailwindcss-postcss/src/__snapshots__/index.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
169169
170170
::placeholder {
171171
opacity: 1;
172-
color: color-mix(in oklab, currentColor 50%, transparent);
172+
color: oklab(from currentColor l a b / 50%);
173173
}
174174
175175
textarea {

packages/tailwindcss/preflight.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ textarea,
285285

286286
/*
287287
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
288-
2. Set the default placeholder color to a semi-transparent version of the current text color.
288+
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)
289289
*/
290290

291291
::placeholder {
292292
opacity: 1; /* 1 */
293-
color: color-mix(in oklab, currentColor 50%, transparent); /* 2 */
293+
color: oklab(from currentColor l a b / 50%); /* 2 */
294294
}
295295

296296
/*

packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap

+9-9
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ exports[`border-* 1`] = `
8484
}
8585
8686
.border-current\\/50 {
87-
border-color: color-mix(in oklab, currentColor 50%, transparent);
87+
border-color: oklab(from currentColor l a b / 50%);
8888
}
8989
9090
.border-inherit {
@@ -206,7 +206,7 @@ exports[`border-b-* 1`] = `
206206
}
207207
208208
.border-b-current\\/50 {
209-
border-bottom-color: color-mix(in oklab, currentColor 50%, transparent);
209+
border-bottom-color: oklab(from currentColor l a b / 50%);
210210
}
211211
212212
.border-b-inherit {
@@ -328,7 +328,7 @@ exports[`border-e-* 1`] = `
328328
}
329329
330330
.border-e-current\\/50 {
331-
border-inline-end-color: color-mix(in oklab, currentColor 50%, transparent);
331+
border-inline-end-color: oklab(from currentColor l a b / 50%);
332332
}
333333
334334
.border-e-inherit {
@@ -450,7 +450,7 @@ exports[`border-l-* 1`] = `
450450
}
451451
452452
.border-l-current\\/50 {
453-
border-left-color: color-mix(in oklab, currentColor 50%, transparent);
453+
border-left-color: oklab(from currentColor l a b / 50%);
454454
}
455455
456456
.border-l-inherit {
@@ -572,7 +572,7 @@ exports[`border-r-* 1`] = `
572572
}
573573
574574
.border-r-current\\/50 {
575-
border-right-color: color-mix(in oklab, currentColor 50%, transparent);
575+
border-right-color: oklab(from currentColor l a b / 50%);
576576
}
577577
578578
.border-r-inherit {
@@ -694,7 +694,7 @@ exports[`border-s-* 1`] = `
694694
}
695695
696696
.border-s-current\\/50 {
697-
border-inline-start-color: color-mix(in oklab, currentColor 50%, transparent);
697+
border-inline-start-color: oklab(from currentColor l a b / 50%);
698698
}
699699
700700
.border-s-inherit {
@@ -816,7 +816,7 @@ exports[`border-t-* 1`] = `
816816
}
817817
818818
.border-t-current\\/50 {
819-
border-top-color: color-mix(in oklab, currentColor 50%, transparent);
819+
border-top-color: oklab(from currentColor l a b / 50%);
820820
}
821821
822822
.border-t-inherit {
@@ -938,7 +938,7 @@ exports[`border-x-* 1`] = `
938938
}
939939
940940
.border-x-current\\/50 {
941-
border-inline-color: color-mix(in oklab, currentColor 50%, transparent);
941+
border-inline-color: oklab(from currentColor l a b / 50%);
942942
}
943943
944944
.border-x-inherit {
@@ -1060,7 +1060,7 @@ exports[`border-y-* 1`] = `
10601060
}
10611061
10621062
.border-y-current\\/50 {
1063-
border-block-color: color-mix(in oklab, currentColor 50%, transparent);
1063+
border-block-color: oklab(from currentColor l a b / 50%);
10641064
}
10651065
10661066
.border-y-inherit {

packages/tailwindcss/src/compat/plugin-api.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3860,7 +3860,7 @@ describe('matchUtilities()', () => {
38603860
}
38613861
38623862
.scrollbar-current\\/45 {
3863-
scrollbar-color: color-mix(in oklab, currentColor 45%, transparent);
3863+
scrollbar-color: oklab(from currentColor l a b / 45%);
38643864
}"
38653865
`)
38663866
})

packages/tailwindcss/src/utilities.test.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -7984,7 +7984,7 @@ test('accent', async () => {
79847984
}
79857985
79867986
.accent-current\\/50, .accent-current\\/\\[0\\.5\\], .accent-current\\/\\[50\\%\\] {
7987-
accent-color: color-mix(in oklab, currentColor 50%, transparent);
7987+
accent-color: oklab(from currentColor l a b / 50%);
79887988
}
79897989
79907990
.accent-inherit {
@@ -8099,7 +8099,7 @@ test('caret', async () => {
80998099
}
81008100
81018101
.caret-current\\/50, .caret-current\\/\\[0\\.5\\], .caret-current\\/\\[50\\%\\] {
8102-
caret-color: color-mix(in oklab, currentColor 50%, transparent);
8102+
caret-color: oklab(from currentColor l a b / 50%);
81038103
}
81048104
81058105
.caret-inherit {
@@ -8212,7 +8212,7 @@ test('divide-color', async () => {
82128212
}
82138213
82148214
:where(.divide-current\\/50 > :not(:last-child)), :where(.divide-current\\/\\[0\\.5\\] > :not(:last-child)), :where(.divide-current\\/\\[50\\%\\] > :not(:last-child)) {
8215-
border-color: color-mix(in oklab, currentColor 50%, transparent);
8215+
border-color: oklab(from currentColor l a b / 50%);
82168216
}
82178217
82188218
:where(.divide-inherit > :not(:last-child)) {
@@ -10140,11 +10140,11 @@ test('bg', async () => {
1014010140
}
1014110141
1014210142
.bg-current\\/50, .bg-current\\/\\[0\\.5\\], .bg-current\\/\\[50\\%\\] {
10143-
background-color: color-mix(in oklab, currentColor 50%, transparent);
10143+
background-color: oklab(from currentColor l a b / 50%);
1014410144
}
1014510145
1014610146
.bg-current\\/\\[var\\(--bg-opacity\\)\\] {
10147-
background-color: color-mix(in oklab, currentColor var(--bg-opacity), transparent);
10147+
background-color: oklab(from currentColor l a b / var(--bg-opacity));
1014810148
}
1014910149
1015010150
.bg-inherit {
@@ -10662,11 +10662,11 @@ test('bg', async () => {
1066210662
),
1066310663
).toMatchInlineSnapshot(`
1066410664
".bg-current\\/custom {
10665-
background-color: color-mix(in oklab, currentColor var(--opacity-custom, var(--custom-opacity)), transparent);
10665+
background-color: oklab(from currentColor l a b / var(--opacity-custom, var(--custom-opacity)));
1066610666
}
1066710667
1066810668
.bg-current\\/half {
10669-
background-color: color-mix(in oklab, currentColor var(--opacity-half, .5), transparent);
10669+
background-color: oklab(from currentColor l a b / var(--opacity-half, .5));
1067010670
}
1067110671
1067210672
.\\[color\\:red\\]\\/half {
@@ -10760,7 +10760,7 @@ test('from', async () => {
1076010760
}
1076110761
1076210762
.from-current\\/50, .from-current\\/\\[0\\.5\\], .from-current\\/\\[50\\%\\] {
10763-
--tw-gradient-from: color-mix(in oklab, currentColor 50%, transparent);
10763+
--tw-gradient-from: oklab(from currentColor l a b / 50%);
1076410764
--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));
1076510765
}
1076610766
@@ -10986,7 +10986,7 @@ test('via', async () => {
1098610986
}
1098710987
1098810988
.via-current\\/50, .via-current\\/\\[0\\.5\\], .via-current\\/\\[50\\%\\] {
10989-
--tw-gradient-via: color-mix(in oklab, currentColor 50%, transparent);
10989+
--tw-gradient-via: oklab(from currentColor l a b / 50%);
1099010990
--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);
1099110991
--tw-gradient-stops: var(--tw-gradient-via-stops);
1099210992
}
@@ -11208,7 +11208,7 @@ test('to', async () => {
1120811208
}
1120911209
1121011210
.to-current\\/50, .to-current\\/\\[0\\.5\\], .to-current\\/\\[50\\%\\] {
11211-
--tw-gradient-to: color-mix(in oklab, currentColor 50%, transparent);
11211+
--tw-gradient-to: oklab(from currentColor l a b / 50%);
1121211212
--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));
1121311213
}
1121411214
@@ -11735,7 +11735,7 @@ test('fill', async () => {
1173511735
}
1173611736
1173711737
.fill-current\\/50, .fill-current\\/\\[0\\.5\\], .fill-current\\/\\[50\\%\\] {
11738-
fill: color-mix(in oklab, currentColor 50%, transparent);
11738+
fill: oklab(from currentColor l a b / 50%);
1173911739
}
1174011740
1174111741
.fill-inherit {
@@ -11872,7 +11872,7 @@ test('stroke', async () => {
1187211872
}
1187311873
1187411874
.stroke-current\\/50, .stroke-current\\/\\[0\\.5\\], .stroke-current\\/\\[50\\%\\] {
11875-
stroke: color-mix(in oklab, currentColor 50%, transparent);
11875+
stroke: oklab(from currentColor l a b / 50%);
1187611876
}
1187711877
1187811878
.stroke-inherit {
@@ -12848,7 +12848,7 @@ test('placeholder', async () => {
1284812848
}
1284912849
1285012850
.placeholder-current\\/50::placeholder, .placeholder-current\\/\\[0\\.5\\]::placeholder, .placeholder-current\\/\\[50\\%\\]::placeholder {
12851-
color: color-mix(in oklab, currentColor 50%, transparent);
12851+
color: oklab(from currentColor l a b / 50%);
1285212852
}
1285312853
1285412854
.placeholder-inherit::placeholder {
@@ -12997,9 +12997,9 @@ test('decoration', async () => {
1299712997
}
1299812998
1299912999
.decoration-current\\/50, .decoration-current\\/\\[0\\.5\\], .decoration-current\\/\\[50\\%\\] {
13000-
-webkit-text-decoration-color: color-mix(in oklab, currentColor 50%, transparent);
13001-
-webkit-text-decoration-color: color-mix(in oklab, currentColor 50%, transparent);
13002-
text-decoration-color: color-mix(in oklab, currentColor 50%, transparent);
13000+
-webkit-text-decoration-color: oklab(from currentColor l a b / 50%);
13001+
-webkit-text-decoration-color: oklab(from currentColor l a b / 50%);
13002+
text-decoration-color: oklab(from currentColor l a b / 50%);
1300313003
}
1300413004
1300513005
.decoration-inherit {
@@ -14702,7 +14702,7 @@ test('outline', async () => {
1470214702
}
1470314703
1470414704
.outline-current\\/50, .outline-current\\/\\[0\\.5\\], .outline-current\\/\\[50\\%\\] {
14705-
outline-color: color-mix(in oklab, currentColor 50%, transparent);
14705+
outline-color: oklab(from currentColor l a b / 50%);
1470614706
}
1470714707
1470814708
.outline-inherit {
@@ -15152,7 +15152,7 @@ test('text', async () => {
1515215152
}
1515315153
1515415154
.text-current\\/50, .text-current\\/\\[0\\.5\\], .text-current\\/\\[50\\%\\] {
15155-
color: color-mix(in oklab, currentColor 50%, transparent);
15155+
color: oklab(from currentColor l a b / 50%);
1515615156
}
1515715157
1515815158
.text-inherit {
@@ -15321,7 +15321,7 @@ test('shadow', async () => {
1532115321
}
1532215322
1532315323
.shadow-current\\/50, .shadow-current\\/\\[0\\.5\\], .shadow-current\\/\\[50\\%\\] {
15324-
--tw-shadow-color: color-mix(in oklab, currentColor 50%, transparent);
15324+
--tw-shadow-color: oklab(from currentColor l a b / 50%);
1532515325
}
1532615326
1532715327
.shadow-inherit {
@@ -15543,7 +15543,7 @@ test('inset-shadow', async () => {
1554315543
}
1554415544
1554515545
.inset-shadow-current\\/50, .inset-shadow-current\\/\\[0\\.5\\], .inset-shadow-current\\/\\[50\\%\\] {
15546-
--tw-inset-shadow-color: color-mix(in oklab, currentColor 50%, transparent);
15546+
--tw-inset-shadow-color: oklab(from currentColor l a b / 50%);
1554715547
}
1554815548
1554915549
.inset-shadow-inherit {
@@ -15781,7 +15781,7 @@ test('ring', async () => {
1578115781
}
1578215782
1578315783
.ring-current\\/50, .ring-current\\/\\[0\\.5\\], .ring-current\\/\\[50\\%\\] {
15784-
--tw-ring-color: color-mix(in oklab, currentColor 50%, transparent);
15784+
--tw-ring-color: oklab(from currentColor l a b / 50%);
1578515785
}
1578615786
1578715787
.ring-inherit {
@@ -16120,7 +16120,7 @@ test('inset-ring', async () => {
1612016120
}
1612116121
1612216122
.inset-ring-current\\/50, .inset-ring-current\\/\\[0\\.5\\], .inset-ring-current\\/\\[50\\%\\] {
16123-
--tw-inset-ring-color: color-mix(in oklab, currentColor 50%, transparent);
16123+
--tw-inset-ring-color: oklab(from currentColor l a b / 50%);
1612416124
}
1612516125
1612616126
.inset-ring-inherit {
@@ -16364,7 +16364,7 @@ test('ring-offset', async () => {
1636416364
}
1636516365
1636616366
.ring-offset-current\\/50, .ring-offset-current\\/\\[0\\.5\\], .ring-offset-current\\/\\[50\\%\\] {
16367-
--tw-ring-offset-color: color-mix(in oklab, currentColor 50%, transparent);
16367+
--tw-ring-offset-color: oklab(from currentColor l a b / 50%);
1636816368
}
1636916369
1637016370
.ring-offset-inherit {

packages/tailwindcss/src/utilities.ts

+7
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ export function withAlpha(value: string, alpha: string): string {
136136
alpha = `${alphaAsNumber * 100}%`
137137
}
138138

139+
// Use the `oklab(…)` function when applying alpha to `currentColor` to work
140+
// around a crash with Safari 16.4 and 16.5
141+
// https://github.com/tailwindlabs/tailwindcss/issues/17194
142+
if (value === 'currentColor') {
143+
return `oklab(from currentColor l a b / ${alpha})`
144+
}
145+
139146
return `color-mix(in oklab, ${value} ${alpha}, transparent)`
140147
}
141148

0 commit comments

Comments
 (0)