Ant Design Svelte

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.

Project
Not saved yet
boxShadowTertiary: 0 1px 2px 0 rgba(0,0,0,0.05), 0 1px 6px -1px rgba(0,0,0,0.03), 0 2px 4px 0 rgba(0,0,0,0.03)

Surface shadow

The card reads the tokens of the current theme and saves the entered text when changing the design.

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.

Surface
Contact shadow
Surface
Soft shadow
Surface
Combined layers
Compact and soft shadows together separate the surface from the background.

Adapted from the guide by Ant Design. MIT.