Text✨ Premium

3D Shadow Depth

Pure-CSS multi-layer 3D shadow — seven stacked text-shadow levels create the illusion that text rises on hover.

CSS3DHover

You'll get access to the interactive demo with a free account.

This effect is part of Effect.Labs — 811 vanilla effects, some free, some premium. Text has 56 effects, including 4 free. Explore the category →

3 usage examples

Main headline — Dark-mode SaaS landing page — 3D Shadow Depth example 1

① Main headline — Dark-mode SaaS landing page

WhenA short keyword or product title in one or two lines in the first section of a dark-themed landing page.
WhyLarge font sizes make every shadow layer clearly visible. The hover lift creates immediate interactivity and visually separates the headline from the rest of the hierarchy.
Settingsfont-size: 5rem–7rem, font-weight: 800, dark background (#0a0a0f or gradient toward #111827). Shadow colors derived as progressively darker shades of the brand's main color.
Game-over screen — Browser game or gamified interface — 3D Shadow Depth example 2

② Game-over screen — Browser game or gamified interface

WhenA massive end-of-game text ("GAME OVER", "LEVEL 4", "NEW RECORD") filling the screen in a browser game, interactive quiz, or heavily gamified application.
WhyAt large size, each <code>text-shadow</code> layer visually mimics stacked LED pixels — the 3D effect becomes a metaphor for retro electronic displays. Hover creates the illusion that the text lifts out of the screen, amplified by the near-black background.
Settingsfont-size: 4rem–6rem, font-weight: 800, bright red (#ef4444) on near-black background. Shadow layers in progressively darker red shades (#dc2626#b91c1c#991b1b#7f1d1d#450a0a). Enhanced by CSS scanlines on the background.
Key figure — Metric card in a dark dashboard — 3D Shadow Depth example 3

③ Key figure — Metric card in a dark dashboard

WhenA KPI (uptime rate, score, user count, conversion rate) as the primary value in a card in a dark-themed dashboard.
WhyStacked depth gives a sense of solidity to the data and draws the eye to the primary value. The effect stays static until the user interacts — no distraction.
Settingsfont-size: 4rem–5rem, font-weight: 800, color matching metric status (indigo / emerald / amber). Card container with border: 1px solid rgba(255,255,255,0.08) to frame the value.

How it works

At rest, four text-shadow layers build the 3D depth: each layer shifts 1 px further bottom-right (1px 1px4px 4px) and uses a progressively darker indigo shade (#4f46e5#4338ca#3730a3#312e81). A fifth semi-transparent black blur (rgba(0,0,0,.5) 5px 5px 10px) adds the ambient cast shadow. The stack simulates a glyph extruded from a flat surface.

On hover, text-shadow extends to seven layers (up to 7px 7px) with three extra levels in the deepest shade (#1e1b4b), and the cast shadow deepens to rgba(0,0,0,.6) 8px 8px 15px. Simultaneously, transform: translate(-3px, -3px) shifts the text toward the top-left — this inverse offset reveals the additional layers and creates the illusion that the glyph rises from the surface.

The transition: .3s property animates interpolation between both states. The CSS engine interpolates text-shadow layer by layer (1:1 matching between the two lists) and transform in parallel — no JavaScript is needed. For transform to apply to an inline <span>, the element must be a flex item (direct child of a flex container) or declared display: inline-block.

Accessibility

  • prefers-reduced-motion not implemented: the code contains no @media (prefers-reduced-motion: reduce) rule — the hover transition plays regardless of system preferences. Add @media (prefers-reduced-motion: reduce) { .text-3d-shadow { transition: none; } } if the audience includes motion-sensitive users.
  • The text remains native DOM content — screen readers read it directly, no ARIA attributes are needed.
  • The effect is purely decorative: with CSS disabled, text is fully readable. No information is conveyed exclusively through the shadow.
  • Contrast: #6366f1 on #0a0a0f ≈ 4.9:1 — WCAG AA compliant for large text (≥ 24 px bold). Insufficient for standard body text — adapt the color for smaller sizes.
  • The hover state (7 layers + translate) is pointer-only. Keyboard users will not see it. If this state is meaningful, add :focus alongside :hover in the selectors.

Browser compatibility

Requires only text-shadow, transform, and transition — supported in all browsers since 2013. Zero external dependencies.

Chrome 36+✓ Full
Firefox 16+✓ Full
Safari 9+✓ Full
Edge 12+✓ Full
Mobile iOS✓ Full
Android Chrome✓ Full

Without these CSS properties (very old browsers), text renders without shadow or animation — no errors, no JS involved.

The code

HTML structure to paste into your page (CSS + JS available with a premium account):

index.html — structure
<div class="demo-preview">
  <!-- Apply text-3d-shadow to any text element -->
  <span class="demo-text text-3d-shadow">Your text</span>
</div>

<!-- Or directly on a semantic heading -->
<!-- (display:inline-block required if element is not a flex item) -->
<h1 class="text-3d-shadow"
    style="font-size:4rem;font-weight:800;display:inline-block">
  Your title
</h1>
🔒 Unlock the full code — from €2.99 the first month

Full HTML + CSS + JS, copy-paste ready — with hundreds of premium effects.

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
color (in .text-3d-shadow) #6366f1 Main text color. Shadow layer shades should be progressively darker versions of this color to maintain 3D extrusion coherence.
text-shadow (rest — .text-3d-shadow) #4f46e5 1px 1px 0, #4338ca 2px 2px 0, #3730a3 3px 3px 0, #312e81 4px 4px 0, rgba(0,0,0,.5) 5px 5px 10px Rest-state depth (4 layers + cast shadow). Each layer adds 1 px more offset — increase the step (2px, 3px…) for a stronger effect or reduce layer count for subtle relief.
text-shadow (hover — .text-3d-shadow:hover) … #1e1b4b 5px 5px 0, #1e1b4b 6px 6px 0, #1e1b4b 7px 7px 0, rgba(0,0,0,.6) 8px 8px 15px Maximum depth on hover (7 layers). The 3 extra layers in #1e1b4b create the space that produces the lift illusion. Adjust their color if the background is not near-black.
transform (in .text-3d-shadow:hover) translate(-3px, -3px) Text shift on hover. Set values to roughly half the total shadow depth (here 7 px → 3–4 px). Too high = visible slide; too low = weakened illusion.
transition (in .text-3d-shadow) .3s Hover transition duration. 0.2s = responsive, 0.5s = dramatic. Can include easing: transition: .3s ease-out.
font-size (in .demo-text) 2.5rem Effect is legible from ≈ 2rem and optimal above 3rem. Below 1.2rem, layers overlap and the illusion disappears.
font-weight (in .demo-text) 800 Heavy weight widens glyphs and amplifies the visible surface of each shadow layer. Weight 700 works well; weight 400 (normal) significantly reduces the effect.

FAQ

No, the effect is 100% CSS. Two selectors (.text-3d-shadow and .text-3d-shadow:hover) are all you need — no JS file to load, no initialization. It works in static pages, CSS-capable HTML emails, and any front-end framework (React, Vue, Svelte) without configuration.
Pick your main color, then generate 4–7 progressively darker shades — for example in HSL by reducing lightness by 5–8% per layer. Example for blue: #3b82f6 → #2563eb → #1d4ed8 → #1e40af → #1e3a8a. The deepest layer can approach black to simulate the cast shadow.
Yes. Simply add class="text-3d-shadow" to as many elements as needed. Each instance is fully autonomous thanks to pure CSS — no selector conflicts, no JavaScript coordination.