Part of the jedee wiki — An LLM wiki, written by Claude Code, about the methods and techniques behind this site.

Shadows

On GitHub: , updated

A single box-shadow is a blurred copy of the element’s outline, moved and colored. It has one offset, one blur and one color, so it falls off in a straight ramp: either a tight dark edge or a wide gray haze, never the dense-near, soft-far shape of a shadow in a room. The fix that has become standard is to stack several shadows on the same element, each larger and fainter than the last.

Layered shadows

Tobias Ahlin’s Smoother & sharper shadows with layered box-shadows (2019) is the origin of the technique. Each layer doubles the offset and blur of the one before, and every layer gets the same low alpha, so the shadow is densest where the layers overlap, near the object, and thins out as only the larger layers reach:

.thumb {
  box-shadow:
    0 1px 1px hsl(0 0% 0% / 0.075),
    0 2px 2px hsl(0 0% 0% / 0.075),
    0 4px 4px hsl(0 0% 0% / 0.075),
    0 8px 8px hsl(0 0% 0% / 0.075),
    0 16px 16px hsl(0 0% 0% / 0.075);
}

More layers means a lower alpha per layer for the same overall depth. Ahlin’s example uses 0.12; anything between about 0.05 and 0.15 reads as a shadow rather than a smudge.

Josh Comeau’s Designing beautiful shadows in CSS builds on it with three further ideas:

  • One light source for the whole page. Every shadow on the site should fall the same way, so the horizontal offset is a fixed share of the vertical one. With the light up and to the left, x = y / 2 puts every shadow down and a little to the right.
  • Elevation as a scale. A low, a medium and a high shadow, each a set of layers, rather than a new value per component. His shadow palette generator produces the three as custom properties, using negative spread on the larger layers to keep them tucked under the object.
  • Tinted shadows. A shadow in pure black over a colored page looks gray and dirty, because a real shadow is the surface color with less light on it. Using a darker, desaturated version of the page’s hue instead of black keeps it clean.

Philipp Brumm’s Smooth Shadow tool, which Comeau credits as his inspiration and which is now offline, spaced the layers on an easing curve instead of doubling them, which gives a very long, soft fall-off suited to large floating panels.

Dark mode

A shadow is darkness subtracted from a lit surface. On a near-black page there is almost no light left to subtract, so the same alphas that read clearly on white vanish. Dark-theme shadows need several times the opacity to show at all, and they stay subtle even then; elevation on a dark page is carried mostly by surfaces that get lighter as they rise. Keeping the layer geometry and scaling only the alpha keeps the two themes recognizably the same shadow:

:root { --shadow-color: 220 15% 30%; --shadow-k: 1; }
:root[data-theme='dark'] { --shadow-color: 0 0% 0%; --shadow-k: 2.4; }

.thumb {
  box-shadow:
    0 1px 1px hsl(var(--shadow-color) / calc(0.075 * var(--shadow-k))),
    /* … the other four layers the same way */;
}

Painted light and cast shadow

An object built in CSS, a book or a sheet of paper, often carries two kinds of shade: light painted onto its surface with gradients (a highlight toward the light, darkening away from it), and the shadow it casts on the page. The two have to agree, and they do not weigh the same in both themes. On a light page, strong darkening on the object reads as the object being dirty or in shade, while its cast shadow is faint; the eye wants the reverse, a surface that stays bright and a shadow that lands beside it. So in light mode the painted darkening stays faint and the cast shadow does the work, offset away from the light. On a dark page the painted light is what gives the object form, and the cast shadow can barely show, so the balance flips back.

In jedee

Since 2026-12-03 the site has three shadow levels, defined in global/base/variables.css: --shadow-low, --shadow and --shadow-high. Each is Ahlin’s five equal layers, doubling, with only the reach (the largest layer’s drop and blur) and the strength per layer changing between levels. Every layer takes its color from one --shadow-ink, which carries the theme:

--shadow-ink: light-dark(rgb(65 73 88 / 0.42), rgb(0 0 0));
--shadow:
  0 0.44px 0.44px color-mix(in srgb, var(--shadow-ink) 19.2%, transparent),
  /* … 0.88, 1.75, 3.5 and 7px the same way */;

Since 2026-12-04 the light ink is worked out from the base color like the other theme colors (see Base color system): oklch(from var(--color-base) var(--l-shadow) … / var(--alpha-shadow)), which gives the same #414958 at 0.42. The line above stays as the fallback for browsers without relative colors.

color-mix() with transparent scales the ink’s opacity, so 19.2% of the dark ink is black at 0.19 a layer and 19.2% of the light ink is the blue-gray at 0.08. The ratio between the themes (2.4) lives in the ink’s light alpha, so no component needs a dark-theme rule for its shadow; seven such rules were deleted. The rule in DESIGN.md is that nothing invents a shadow: a component takes one of the three levels.

LevelReach, strengthUsed by
--shadow-low2px, 2.5%cover tiles at rest (see Duotone), inline code (see Syntax highlighting)
--shadow7px, 8%every prose image, the place map, the YouTube embed, the book’s cover, cover tiles on hover
--shadow-high14.5px, 10%the mega-menu, the search panel, tooltips (see Tooltips), the map popup, pull-to-refresh, the book’s back cover

Strength is the light theme’s opacity per layer; dark is 2.4 times that, in black. The first values (3, 16 and 32px) were tuned by eye on 2026-12-04 in the tweak panel on :8090, whose Shadows section overrides the three levels on the real page with sliders for reach, strength, the dark factor and the tint. All three came out tighter and closer to the page; the low level is barely a contact line.

The shadows used to be separate recipes in src/_includes/themes/jedee/tokens/shadows.json (panel, popup, chip, thumb, lift, lift-raised), stored as Penpot-shaped layers and composed into --box-shadow-* custom properties by dtcgShadowToTailwind() (see Tailwind), each with a -dark twin that a dark-theme rule swapped in. panel, popup and chip were two layers, a tight contact shadow plus a wide soft one. Since 2026-12-04 the file holds the three levels as layers (low, default, high, each with a -dark twin) for the Design System page and the design file, plus thumb-cast, which the pamphlet still reads. ⚠️ They are copies of the CSS values, so a change to one needs the other.

thumb was picked from a local comparison page that put Ahlin’s layers, Comeau’s low, medium and high, Brumm’s eased layers, the existing popup and a value from the Penpot file on six album covers from near-black to near-white, two photos and two plain squares, in both themes. In light mode it is tinted with #414958, a dark blue-gray from the site’s text color, at 0.075 a layer; in dark mode it is black at 0.18 a layer.

thumb-cast came out of the pamphlet on the Bethink Yourselves! note. Its cover had a gradient darkening to 34% brown at the bottom right, which looked heavy on the light page while its shadow was faint. In light mode the darkening is now 10%, the highlight 22% and the spine shade 15%, and the shadow is thumb-cast (offsets 0.5, 1, 2, 4 and 8px across, alpha 0.133 a layer). The dark theme keeps the stronger painted light, and thumb-cast-dark equals thumb-dark. The three amounts are custom properties at the top of local/pamphlet.css, with the dark values in its dark-theme rules:

.pamphlet {
  --pamphlet-paper: #e0d0b0;
  --pamphlet-shadow: var(--box-shadow-thumb-cast);
  --pamphlet-highlight: 0.22;
  --pamphlet-falloff: 0.1;
  --pamphlet-spine: 0.15;
}

A shadow that grows on hover needs a pair with the same number of layers. Browsers interpolate box-shadow lists layer by layer and pad a shorter list with transparent layers, so going from thumb (five layers) to panel (two) swapped one shape for another instead of growing it; in light mode panel was even fainter than thumb, so the hovered cover seemed to sink. lift and lift-raised were added on 2026-11-29 for that reason, and it is why all three levels now have five layers: a cover tile goes from --shadow-low to --shadow and the shadow grows.

None of this is Eleventy Excellent stock: EE ships no shadow tokens, and the layer format exists because Penpot stores shadows that way.

Raw source: src/_raw/dev-notes/How the shadow tokens were picked.md

Keyboard shortcuts

⌘K
Open the search
↓ ↑
Move through the search results
Enter
Open the selected result
Esc
Close the search or this list, or turn off the grid and lines
⌥G
Show or hide the layout grid
⌥R
Show or hide the rhythm lines
⌥L
Open this list