Shadows and layers
The shadow helps to see which surface is above the other and what the open window is connected to. Use it consistently with the background, borders, and element position.
Surface levels
Ant Design recommendations highlight four semantic levels. They describe the role of the surface, not the required value of a particular CSS design token.
| Level | Behavior | Example |
|---|---|---|
| Main | The element is in the page plane | Field Input |
| Elated | Slight selection of an object during interaction | Card Card |
| Popup | The panel is bound to the control element | Dropdown, Popover |
| Conversational | Separate task on top of current page | Modal |
Don't assign maximum shadow to all blocks; this will cause them to compete for attention. A regular field often only needs a border and a focus state. The structure of the page and the spacing between blocks is described by layout guide.
Tokens of the current topic
For custom surfaces, boxShadow, boxShadowSecondary and boxShadowTertiary are available from theme.useToken(). To have no shadow, use the CSS value none. Components can also have their own appearance settings; they are listed on their API pages.
Token names do not specify a strict height scale. In the current theme, @woodger/antd boxShadow and boxShadowSecondary can be the same. Don't expect that each token will necessarily create a visually distinct stage. Compare actual values and surface meaning.
A token can contain several shadows: the compact part helps to separate the border, the more blurry part helps to show the distance. Store the entire value instead of copying one fragment. Rules theme settings allow you to override the appearance of the application.
Surface in practice
Select a token, enter a project name and save it. The card uses the selected value in the local style; the line below it shows the token name and its current CSS value.
Then switch the general theme in the top menu. The example reads the tokens of the current provider, and the entered name remains in the Svelte state. Selecting none removes the shadow while preserving the contents of the card. The example does not change the global design of the remaining Card or popup.
Surface shadow
The card reads the tokens of the current theme and saves the entered text when changing the design.
<script lang="ts">
import { Button, Card, Input, RadioGroup, theme } from '@woodger/antd';
let selected = $state<
'none' | 'boxShadowTertiary' | 'boxShadowSecondary' | 'boxShadow'
>('boxShadowTertiary');
let draft = $state('');
let saved = $state('');
const current = theme.useToken();
const shadow = $derived(selected === 'none' ? 'none' : current.token[selected]);
</script>
<style>
.example, .fields {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
}
.surface {
min-width: 0;
padding: 24px;
border-radius: var(--ant-border-radius-lg);
background: var(--ant-color-bg-layout);
}
label {
display: grid;
gap: 8px;
}
output { overflow-wrap: anywhere; }
.token {
font-size: 12px;
font-family: monospace;
}
</style>
<div class="example">
<RadioGroup
aria-label={("Surface shadow")}
orientation="vertical"
bind:value={selected}
options={([
{ value: 'none', label: "Without shadow" },
{ value: 'boxShadowTertiary', label: 'boxShadowTertiary' },
{ value: 'boxShadowSecondary', label: 'boxShadowSecondary' },
{ value: 'boxShadow', label: 'boxShadow' }
])}
/>
<div class="surface">
<Card
class="guide-shadow-card"
title={("Project")}
variant="borderless"
style={`box-shadow:${shadow}`}
>
<div class="fields">
<label>{("Name\n ")}<Input aria-label={("Name in the shadow example")} bind:value={draft} style="width:100%" />
</label>
<div><Button type="primary" disabled={!draft.trim()}
onclick={() => { saved = draft.trim(); }}>{("Save")}</Button></div>
<output aria-label={("Result of shadow example")}>{(saved ? `Saved: ${saved}` : "Not saved yet")}</output>
</div>
</Card>
</div>
<output
class="token"
aria-label={("Shadow of the current topic")}
>{selected}: {shadow}</output>
</div>
Light and dark theme
Compare a surface along with its surroundings. On a dark background, the contrast between the surfaces and the border can be more noticeable than the shadow itself. Use background and text tokens to ensure the card remains readable when changing themes.
Check the surface in a narrow window: the indentation around it should leave room for shadow, and the card itself should accommodate fields and actions. Don't cut off important content for the sake of decorative effect.
Shadow composition
A shadow has colour, offset, blur and spread. A compact layer defines the edge; a softer layer conveys distance from the background. Below, the same Card shows each layer separately and their combination. These values illustrate the principle; use the complete current-theme token in an application.
Adapted from the guide by Ant Design. MIT.