Skip to main content

Elevation & Surfaces

trust-ui v2 organizes UI into 3 surface tiers. Pick the right tier for each component and you get coherent depth across the whole interface.

Tier model

TierUsed byStyle
Tier 1 — BasePage backgroundvar(--tui-bg) solid
Tier 2 — RaisedCard, Button (secondary), Input, Table, Tabs panelvar(--tui-bg-subtle) + var(--tui-border) 1px + var(--tui-shadow-sm)
Tier 3 — Elevated GlassDialog, Popover, Toast, Menu.tui-glass utility (translucent + backdrop-blur)

Tooltip is intentionally not Glass — small surfaces benefit from opaque inverse contrast (black bg + white text) for readability.

Shadow scale

Layered shadows that read warm and natural:

TokenValue
--tui-shadow-xs0 1px 2px rgba(15, 16, 26, 0.04)
--tui-shadow-sm0 1px 2px rgba(15, 16, 26, 0.05), 0 1px 3px rgba(15, 16, 26, 0.03)
--tui-shadow-md0 2px 4px rgba(15, 16, 26, 0.06), 0 4px 12px -2px rgba(15, 16, 26, 0.06)
--tui-shadow-lg0 4px 8px rgba(15, 16, 26, 0.06), 0 12px 32px -8px rgba(15, 16, 26, 0.1)
--tui-shadow-xl0 8px 16px rgba(15, 16, 26, 0.08), 0 24px 48px -12px rgba(15, 16, 26, 0.14)

Inset highlight

For premium-feel solid surfaces (gradient buttons), pair the shadow with an inset top highlight to suggest light coming from above:

.button-primary {
background: var(--tui-primary-gradient);
box-shadow: var(--tui-inset-highlight);
}
TokenValue
--tui-inset-highlightinset 0 1px 0 rgba(255, 255, 255, 0.18)

Glass — .tui-glass

The .tui-glass global utility class gives a component the Tier 3 treatment in one line. Two-step fallback chain handles browsers without backdrop-filter:

.tui-glass {
background-color: var(--tui-glass-bg); /* translucent surface */
border: 1px solid var(--tui-glass-border);
box-shadow: var(--tui-glass-shadow);
border-radius: var(--tui-radius-xl);
}

@supports ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
.tui-glass {
backdrop-filter: blur(var(--tui-glass-blur)) saturate(180%);
-webkit-backdrop-filter: blur(var(--tui-glass-blur)) saturate(180%);
}
}

@supports not ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
.tui-glass {
/* Older Android WebView, etc. — drops down to Tier 2 surface */
background-color: var(--tui-bg-subtle);
}
}

Glass tokens

TokenLightDark
--tui-glass-bgrgba(255, 255, 255, 0.72)rgba(24, 25, 34, 0.72)
--tui-glass-borderrgba(255, 255, 255, 0.5)rgba(255, 255, 255, 0.1)
--tui-glass-blur20px20px
--tui-glass-shadowlayered drop + inner highlightdark-tuned variant

Performance note

backdrop-filter is GPU-accelerated but not free — it has measurable cost on mid-range Android. trust-ui only applies Glass to transient surfaces (modals, dropdowns, toasts) that mount on user action, so the cost is bounded. Never apply .tui-glass to a permanent page-background element.

Card elevation prop

The Card component (not yet shipped in v2 — coming) exposes an elevation prop to switch between flat / raised / floating shadow levels without writing CSS. For other components, compose with shadow tokens directly:

<div style={{ boxShadow: 'var(--tui-shadow-md)' }}>
<Card />
</div>