Skip to content

Commit 40e4b0e

Browse files
committed
Add note about gradients and variants to upgrade guide
1 parent 4fce7c0 commit 40e4b0e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/docs/upgrade-guide.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,30 @@ If this change causes any issues in your project, we recommend migrating to a fl
396396
</div>
397397
```
398398

399+
### Using variants with gradients
400+
401+
In v3, overriding part of a gradient with a variant would "reset" the entire gradient, so in this example the `to-*` color would be transparent in dark mode instead of yellow:
402+
403+
```html
404+
<!-- [!code filename:HTML] -->
405+
<!-- [!code classes:dark:from-blue-500] -->
406+
<div class="bg-gradient-to-r from-red-500 to-yellow-400 dark:from-blue-500">
407+
<!-- ... -->
408+
</div>
409+
```
410+
411+
In v4, these values are preserved which is more consistent with how other utilities in Tailwind work.
412+
413+
This means you may need to explicitly use `via-none` if you want to "unset" a three-stop gradient back to a two-stop gradient in a specific state:
414+
415+
```html
416+
<!-- [!code filename:HTML] -->
417+
<!-- [!code classes:dark:via-none] -->
418+
<div class="bg-linear-to-r from-red-500 via-orange-400 to-yellow-400 dark:via-none dark:from-blue-500 dark:to-teal-400">
419+
<!-- ... -->
420+
</div>
421+
```
422+
399423
### Container configuration
400424

401425
In v3, the `container` utility had several configuration options like `center` and `padding` that no longer exist in v4.

0 commit comments

Comments
 (0)