Skip to content

Commit feeb9f1

Browse files
authored
Remove invalid gradient fallbacks (#14705)
Prior to this PR we were providing fallback values for certain CSS variables in our gradient utilities that just weren't necessary and didn't do anything. For example `bg-linear-to-r` was generating this: ```css .bg-linear-to-r { --tw-gradient-position: to right; background-image: linear-gradient( var(--tw-gradient-stops, to right) ); } ``` …but `background-image: linear-gradient(to right)` is not valid CSS and is thrown out by the browser. This PR removes these fallback values entirely since there is nothing sensible to fall back to anyways — you need to combine these utilities with the `from-*`/`to-*` utilities or provide the complete gradient as an arbitrary value for things to make sense. --------- Co-authored-by: Adam Wathan <[email protected]>
1 parent ec24b7a commit feeb9f1

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Fixed
1616

1717
- Ensure `theme` values defined outside of `extend` in JS configuration files overwrite all existing values for that namespace ([#14672](https://github.com/tailwindlabs/tailwindcss/pull/14672))
18+
- Remove unnecessary variable fallbacks in gradient utilities ([#14705](https://github.com/tailwindlabs/tailwindcss/pull/14705))
1819
- _Upgrade (experimental)_: Speed up template migrations ([#14679](https://github.com/tailwindlabs/tailwindcss/pull/14679))
1920
- _Upgrade (experimental)_: Don't generate invalid CSS when migrating a complex `screens` config ([#14691](https://github.com/tailwindlabs/tailwindcss/pull/14691))
2021

packages/tailwindcss/src/utilities.test.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9566,42 +9566,42 @@ test('bg', async () => {
95669566
95679567
.bg-gradient-to-b {
95689568
--tw-gradient-position: to bottom, ;
9569-
background-image: linear-gradient(var(--tw-gradient-stops, to bottom));
9569+
background-image: linear-gradient(var(--tw-gradient-stops));
95709570
}
95719571
95729572
.bg-gradient-to-bl {
95739573
--tw-gradient-position: to bottom left, ;
9574-
background-image: linear-gradient(var(--tw-gradient-stops, to bottom left));
9574+
background-image: linear-gradient(var(--tw-gradient-stops));
95759575
}
95769576
95779577
.bg-gradient-to-br {
95789578
--tw-gradient-position: to bottom right, ;
9579-
background-image: linear-gradient(var(--tw-gradient-stops, to bottom right));
9579+
background-image: linear-gradient(var(--tw-gradient-stops));
95809580
}
95819581
95829582
.bg-gradient-to-l {
95839583
--tw-gradient-position: to left, ;
9584-
background-image: linear-gradient(var(--tw-gradient-stops, to left));
9584+
background-image: linear-gradient(var(--tw-gradient-stops));
95859585
}
95869586
95879587
.bg-gradient-to-r {
95889588
--tw-gradient-position: to right, ;
9589-
background-image: linear-gradient(var(--tw-gradient-stops, to right));
9589+
background-image: linear-gradient(var(--tw-gradient-stops));
95909590
}
95919591
95929592
.bg-gradient-to-t {
95939593
--tw-gradient-position: to top, ;
9594-
background-image: linear-gradient(var(--tw-gradient-stops, to top));
9594+
background-image: linear-gradient(var(--tw-gradient-stops));
95959595
}
95969596
95979597
.bg-gradient-to-tl {
95989598
--tw-gradient-position: to top left, ;
9599-
background-image: linear-gradient(var(--tw-gradient-stops, to top left));
9599+
background-image: linear-gradient(var(--tw-gradient-stops));
96009600
}
96019601
96029602
.bg-gradient-to-tr {
96039603
--tw-gradient-position: to top right, ;
9604-
background-image: linear-gradient(var(--tw-gradient-stops, to top right));
9604+
background-image: linear-gradient(var(--tw-gradient-stops));
96059605
}
96069606
96079607
.bg-linear-\\[1\\.3rad\\] {
@@ -9614,44 +9614,49 @@ test('bg', async () => {
96149614
background-image: linear-gradient(var(--tw-gradient-stops, 125deg));
96159615
}
96169616
9617-
.bg-linear-\\[to_bottom\\], .bg-linear-to-b {
9617+
.bg-linear-\\[to_bottom\\] {
96189618
--tw-gradient-position: to bottom, ;
96199619
background-image: linear-gradient(var(--tw-gradient-stops, to bottom));
96209620
}
96219621
9622+
.bg-linear-to-b {
9623+
--tw-gradient-position: to bottom, ;
9624+
background-image: linear-gradient(var(--tw-gradient-stops));
9625+
}
9626+
96229627
.bg-linear-to-bl {
96239628
--tw-gradient-position: to bottom left, ;
9624-
background-image: linear-gradient(var(--tw-gradient-stops, to bottom left));
9629+
background-image: linear-gradient(var(--tw-gradient-stops));
96259630
}
96269631
96279632
.bg-linear-to-br {
96289633
--tw-gradient-position: to bottom right, ;
9629-
background-image: linear-gradient(var(--tw-gradient-stops, to bottom right));
9634+
background-image: linear-gradient(var(--tw-gradient-stops));
96309635
}
96319636
96329637
.bg-linear-to-l {
96339638
--tw-gradient-position: to left, ;
9634-
background-image: linear-gradient(var(--tw-gradient-stops, to left));
9639+
background-image: linear-gradient(var(--tw-gradient-stops));
96359640
}
96369641
96379642
.bg-linear-to-r {
96389643
--tw-gradient-position: to right, ;
9639-
background-image: linear-gradient(var(--tw-gradient-stops, to right));
9644+
background-image: linear-gradient(var(--tw-gradient-stops));
96409645
}
96419646
96429647
.bg-linear-to-t {
96439648
--tw-gradient-position: to top, ;
9644-
background-image: linear-gradient(var(--tw-gradient-stops, to top));
9649+
background-image: linear-gradient(var(--tw-gradient-stops));
96459650
}
96469651
96479652
.bg-linear-to-tl {
96489653
--tw-gradient-position: to top left, ;
9649-
background-image: linear-gradient(var(--tw-gradient-stops, to top left));
9654+
background-image: linear-gradient(var(--tw-gradient-stops));
96509655
}
96519656
96529657
.bg-linear-to-tr {
96539658
--tw-gradient-position: to top right, ;
9654-
background-image: linear-gradient(var(--tw-gradient-stops, to top right));
9659+
background-image: linear-gradient(var(--tw-gradient-stops));
96559660
}
96569661
96579662
.bg-\\[image\\:var\\(--my-gradient\\)\\] {

packages/tailwindcss/src/utilities.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,12 +2517,12 @@ export function createUtilities(theme: Theme) {
25172517
]) {
25182518
staticUtility(`bg-gradient-to-${value}`, [
25192519
['--tw-gradient-position', `to ${direction},`],
2520-
['background-image', `linear-gradient(var(--tw-gradient-stops, to ${direction}))`],
2520+
['background-image', `linear-gradient(var(--tw-gradient-stops))`],
25212521
])
25222522

25232523
staticUtility(`bg-linear-to-${value}`, [
25242524
['--tw-gradient-position', `to ${direction},`],
2525-
['background-image', `linear-gradient(var(--tw-gradient-stops, to ${direction}))`],
2525+
['background-image', `linear-gradient(var(--tw-gradient-stops))`],
25262526
])
25272527
}
25282528

@@ -2578,7 +2578,7 @@ export function createUtilities(theme: Theme) {
25782578

25792579
return [
25802580
decl('--tw-gradient-position', `from ${value},`),
2581-
decl('background-image', `conic-gradient(var(--tw-gradient-stops,from ${value}))`),
2581+
decl('background-image', `conic-gradient(var(--tw-gradient-stops))`),
25822582
]
25832583
}
25842584
})

0 commit comments

Comments
 (0)