Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 37 ยท Typography, Color and Effects

Shadows, Filters and Backdrop Effects

Add depth and effects with Tailwind v4: box shadows, colored and inset shadows, drop-shadow, text-shadow, blur and color filters, frosted glass and blend modes.

Shadows, blurs and filters give a flat interface depth and polish. They are also easy to overdo, so this lesson pairs each effect with when it makes a design better. Tailwind covers three families: shadows (box, inset, drop and text), filters (blur, brightness, grayscale and friends, applied to the element itself) and backdrop filters (applied to whatever is behind the element).

Box shadows

shadow-{size} adds a layered drop shadow around the element's box. In v4 the scale has one more small step, and the names shifted:

v4 class Use
shadow-2xs a barely-there 1px lift (new in v4)
shadow-xs subtle, for inputs (was shadow-sm in v3)
shadow-sm small cards and buttons (was shadow in v3)
shadow-md raised cards
shadow-lg dropdowns, popovers
shadow-xl, shadow-2xl modals, floating panels
shadow-none remove a shadow

Tint a shadow with a color: shadow-lg shadow-indigo-500/30 produces a glow in the brand color, much nicer than pure gray on colorful buttons. Inset shadows go inside the box: inset-shadow-sm, inset-shadow-indigo-500/40; handy for pressed buttons and recessed inputs. They combine with outer shadows and with rings (see Borders, Rings and Outlines) on the same element.

Rule of thumb: bigger shadow = further from the surface. Make a hover state step up one size (shadow-sm hover:shadow-lg), and keep a page to two or three shadow sizes.

The shadow scale

Drop shadow and text shadow

shadow-* follows the rectangular box. For images with transparency (PNG or SVG icons) the shadow should follow the shape: use drop-shadow-*, which is a CSS filter: drop-shadow-md, drop-shadow-lg, with color support as drop-shadow-sky-500/50.

For text, v4.1 added text shadows: text-shadow-2xs, text-shadow-xs, text-shadow-sm, text-shadow-md, text-shadow-lg, also coloured (text-shadow-black/40). They help lettering stay readable on top of a photograph.

Filters

Filters change how the element itself is drawn:

Class Effect
blur-sm, blur-md, blur-xl Gaussian blur (v4: blur-xs is the smallest)
brightness-50, brightness-125 lighter or darker
contrast-125 more or less contrast
grayscale, grayscale-50 remove color
saturate-150 boost or mute color
sepia warm brown tone
hue-rotate-90 rotate hues around the wheel
invert negative colors

A typical use: images in grayscale that turn colorful on hover, grayscale hover:grayscale-0 transition. Filters can be combined on one element, and they create a new stacking context. Blurring a large area can be expensive on low-end phones, so use it sparingly on big, animated elements.

Backdrop filters: frosted glass

The backdrop-* family applies a filter to what is behind the element, not to the element itself. The famous result is the frosted glass look: a translucent background plus backdrop-blur.

Frosted glass and filters

The glass card needs both parts: a see-through background so the blurred backdrop is visible, and backdrop-blur-*. A solid background hides the effect. Other backdrop utilities mirror the filters: backdrop-brightness-75, backdrop-saturate-150, backdrop-grayscale. Sticky navbars often use bg-white/80 backdrop-blur so content blurs as it scrolls under.

Blend modes

mix-blend-multiply, mix-blend-screen, mix-blend-overlay and friends blend an element with what is behind it, and bg-blend-* blends an element's own background layers (such as an image and a color). Multiply a logo over a colored section, or tint a photo by putting a background color with bg-blend-multiply on it:

HTML
<div class="bg-indigo-500 bg-[url(/samples/sunset.svg)] bg-cover bg-blend-multiply"></div>

Masks

v4.1 also added mask-* utilities that fade an element out along one side: mask-b-from-50% fades the bottom half of a long text preview into nothing. Support is good in current browsers (some need a prefix, which Tailwind adds).

Performance and taste

  • Shadows are cheap; big blurs and backdrop filters are not. Avoid backdrop-blur on elements that cover the whole screen and animate.
  • Prefer subtle. Many modern designs use a 1px ring (ring-1 ring-slate-200) plus a small shadow instead of a heavy one.
  • Respect user preferences for motion and transparency (motion-reduce: and contrast-more: variants exist; chapter 5 covers variants).
  • Do not use shadows to fix poor contrast; fix the colors instead.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which utility makes a shadow follow the outline of a transparent PNG or SVG?

    drop-shadow is a filter that follows the visible shape, while shadow applies to the rectangular box.
  2. 2. What two ingredients make the frosted glass effect?

    backdrop-blur blurs what is behind the element, so the element's own background must be translucent for it to show.
  3. 3. In v4, which class replaced the old shadow-sm look from v3?

    The scale shifted: v3's shadow-sm became shadow-xs, and v3's plain shadow became shadow-sm.
  4. 4. What does grayscale hover:grayscale-0 do to an image?

    grayscale sets the filter; the hover variant removes it, restoring color.

Summary

  • shadow-{2xs..2xl} adds depth; tint with shadow-indigo-500/30, use inset-shadow-* for pressed looks, and drop-shadow-* for shapes.
  • text-shadow-* helps text over images.
  • Filters (blur-*, grayscale, brightness-*, hue-rotate-*) change the element; backdrop-* filters change what is behind it.
  • Pair a translucent background with backdrop-blur-* for glass; use blend modes and masks for finer effects.

Next: Transitions and Transforms