Skip to main content

Module elevation

Module elevation 

Source
Expand description

Elevation::neutral: the design-language-free 6-level (0-5) elevation table, each level a dp value, a v1 shadow mapping, and the surface-container role a surface at that level should paint with.

This crate constructs no other Elevation — a design system builds its own from its own plugin crate (frust-material’s tokens module carries the Material 3 table these numbers originate from, source cited there; frust-cupertino’s carries the subtler iOS-idiom shadow mapping over the same dp ladder). The dp values and shadow math below are the M3 numbers reused verbatim (see crate::theme::Theme::neutral’s module docs).

dp source: https://m3.material.io/styles/elevation (verified 2026-07-17): L0 0dp, L1 1dp, L2 3dp, L3 6dp, L4 8dp, L5 12dp. Component mapping per the same source: L1 = elevated cards/bottom sheets, L2 = nav bar/menus, L3 = FAB/dialogs.

Shadow math is TUNABLE, not an M3-published spec. Material 3’s 2023 direction replaced tonal-overlay tinting with static surface-container roles for most elevated surfaces — the opposite of “primarily tonal overlay post-2023” — but shadows still exist alongside; M3 does not publish exact shadow blur/offset math, so this module defines a documented v1 mapping: y_offset = dp / 2.0 + 1.0, blur_std_dev = dp, shadow color = ColorScheme::shadow at color_alpha ~0.3. A gallery example is the visual check for this mapping; treat it as adjustable, not load- bearing, Frust-specific policy.

§Per-brightness shadows

ElevationLevel carries separate light/dark ShadowSpecs (shadow_light/shadow_dark), selected via ElevationLevel::shadow. Elevation::neutral duplicates the same v1 mapping into both slots — behavior-preserving, byte-identical rendered output on either brightness. A design language whose shadow recipe actually differs by brightness (e.g. Glyph) fills the two slots independently.

Structs§

Elevation
The 6 elevation levels (0-5).
ElevationLevel
One elevation level: its dp value, per-brightness v1 shadow specs, and surface-container role.
ShadowSpec
Y-offset, Gaussian blur standard deviation, and shadow color alpha for one elevation level’s drop shadow. All lengths in logical px; color_alpha multiplies against ColorScheme::shadow’s own alpha (usually opaque black) to get the final translucency — see module docs for the v1 mapping this crate uses.

Enums§

SurfaceRole
Which ColorScheme surface-container role an elevated surface at a given level should paint with — the 2023 static-surface-container-role direction (see module docs), not tonal-overlay tinting.