Skip to content

Commit 020624b

Browse files
committed
Add drop-shadow colors.
1 parent 6d3f29c commit 020624b

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

src/blog/tailwindcss-v4-1/index.mdx

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ We all know that your AI assistant still thinks it's 2023, so here's a list of n
3131
- [New `text-shadow-*` utilities](#new-text-shadow-utilities): Finally, you can use a feature that has been in CSS since 2009.
3232
- [Mask elements with the `mask-*` utilities](#mask-elements-with-the-mask-utilities): Use images and gradients to mask the visibility of elements.
3333
- [Fine-grained text wrapping with `overflow-wrap`](#fine-grained-text-wrapping-with-overflow-wrap): Even the longest German word can't break your layout.
34+
- [Colored `drop-shadow` support](#colored-drop-shadow-support): Box and text shadows have colors, so why not drop shadows.
3435
- [Target input devices with `pointer-*` and `any-pointer-*`](#target-input-devices-with-pointer-and-any-pointer): Touch targets just got easier to style.
3536
- [Align items with `items-baseline-last`](#align-items-with-items-baseline-last): Align flex or grid items to the baseline of the last line of text.
3637
- [Keep content visible with `safe` alignment](#keep-content-visible-with-safe-alignment): Safely align content without worrying about overflow.
@@ -390,6 +391,110 @@ There's not much more to it than that, but here's the [`overflow-wrap`](/docs/ov
390391

391392
---
392393

394+
## Colored `drop-shadow` support
395+
396+
While we were building out `text-shadow` support we thought we might as well add another feature we never got around to implementing: colored drop shadows.
397+
398+
Now you can use utilities like `drop-shadow-indigo-500` and `drop-shadow-cyan-500/50` to change the color of a drop shadow:
399+
400+
<Figure>
401+
402+
<Example>
403+
{
404+
<div className="grid grid-cols-3 items-end gap-8 bg-white max-sm:grid-cols-1">
405+
<div className="flex flex-col items-center">
406+
<p className="mb-3 text-center font-mono text-sm font-medium text-gray-500">drop-shadow-cyan-500/50</p>
407+
<svg className="size-28 text-gray-950/100 drop-shadow-xl drop-shadow-cyan-500/50" viewBox="0 0 84 84">
408+
<path
409+
d="M22.0992 77L2.19922 42.5L22.0992 8H61.8992L81.7992 42.5L61.8992 77H22.0992Z"
410+
className="fill-cyan-500"
411+
/>
412+
</svg>
413+
</div>
414+
<div className="flex flex-col items-center">
415+
<p className="mb-3 text-center font-mono text-sm font-medium text-gray-500">drop-shadow-sky-500/50</p>
416+
<svg className="size-28 text-gray-950/100 drop-shadow-xl drop-shadow-sky-500/50" viewBox="0 0 84 84">
417+
<path
418+
d="M22.0992 77L2.19922 42.5L22.0992 8H61.8992L81.7992 42.5L61.8992 77H22.0992Z"
419+
className="fill-sky-500"
420+
/>
421+
</svg>
422+
</div>
423+
<div className="flex flex-col items-center">
424+
<p className="mb-3 text-center font-mono text-sm font-medium text-gray-500">drop-shadow-indigo-500/50</p>
425+
<svg className="size-28 text-gray-950/100 drop-shadow-xl drop-shadow-indigo-500/50" viewBox="0 0 84 84">
426+
<path
427+
d="M22.0992 77L2.19922 42.5L22.0992 8H61.8992L81.7992 42.5L61.8992 77H22.0992Z"
428+
className="fill-indigo-500"
429+
/>
430+
</svg>
431+
</div>
432+
</div>
433+
}
434+
</Example>
435+
436+
```html
437+
<!-- [!code classes:drop-shadow-cyan-500/50,drop-shadow-blue-500/50,drop-shadow-indigo-500/50] -->
438+
<svg class="fill-cyan-500 drop-shadow-xl drop-shadow-cyan-500/50 ...">...</svg>
439+
<svg class="fill-blue-500 drop-shadow-xl drop-shadow-blue-500/50 ...">...</svg>
440+
<svg class="fill-indigo-500 drop-shadow-xl drop-shadow-indigo-500/50 ...">...</svg>
441+
```
442+
443+
</Figure>
444+
445+
Like with all the other shadow utilities, you can now also adjust the opacity of the default shadow color:
446+
447+
<Figure>
448+
449+
<Example>
450+
{
451+
<div className="grid grid-cols-3 items-end gap-8 bg-white max-sm:grid-cols-1">
452+
<div className="flex flex-col items-center">
453+
<p className="mb-3 text-center font-mono text-sm font-medium text-gray-500">drop-shadow-xl</p>
454+
<svg className="size-28 text-gray-950/100 drop-shadow-xl" viewBox="0 0 84 84">
455+
<path
456+
d="M22.0992 77L2.19922 42.5L22.0992 8H61.8992L81.7992 42.5L61.8992 77H22.0992Z"
457+
className="fill-white"
458+
/>
459+
</svg>
460+
</div>
461+
<div className="flex flex-col items-center">
462+
<p className="mb-3 text-center font-mono text-sm font-medium text-gray-500">drop-shadow-xl/25</p>
463+
<svg className="size-28 text-gray-950/100 drop-shadow-xl/25" viewBox="0 0 84 84">
464+
<path
465+
d="M22.0992 77L2.19922 42.5L22.0992 8H61.8992L81.7992 42.5L61.8992 77H22.0992Z"
466+
className="fill-white"
467+
/>
468+
</svg>
469+
</div>
470+
<div className="flex flex-col items-center">
471+
<p className="mb-3 text-center font-mono text-sm font-medium text-gray-500">drop-shadow-xl/50</p>
472+
<svg className="size-28 text-gray-950/100 drop-shadow-xl/50" viewBox="0 0 84 84">
473+
<path
474+
d="M22.0992 77L2.19922 42.5L22.0992 8H61.8992L81.7992 42.5L61.8992 77H22.0992Z"
475+
className="fill-white"
476+
/>
477+
</svg>
478+
</div>
479+
</div>
480+
}
481+
</Example>
482+
483+
```html
484+
<!-- [!code classes:drop-shadow-xl,drop-shadow-xl/25,drop-shadow-xl/50] -->
485+
<svg class="fill-white drop-shadow-xl ...">...</svg>
486+
<svg class="fill-white drop-shadow-xl/25 ...">...</svg>
487+
<svg class="fill-white drop-shadow-xl/50 ...">...</svg>
488+
```
489+
490+
</Figure>
491+
492+
Using the opacity modifier like this is just a shorthand for setting `drop-shadow-xl` and `text-shadow-black/<opacity>` at the same time.
493+
494+
There isn't anything more to it but here's the `drop-shadow` [documentation](/docs/filter-drop-shadow) anyway.
495+
496+
---
497+
393498
## Target input devices with `pointer-*` and `any-pointer-*`
394499

395500
There's nothing worse than a touch target that is too small to hit with your finger. The new `pointer-*` and `any-pointer-*` variants let you target specific input devices, so you can style your interface elements accordingly.

0 commit comments

Comments
 (0)