Elevation
Surface levels, from the app's background to dialogs, and the shadows that set them apart.
A surface level is a background, edge, shadow, radius and padding that together say how far something sits above the page. Use Surface with a level, rather than styling backgrounds and shadows by hand, so every card, menu and dialog reads at the right height in light and dark.
The levels
From the lowest:
| Level | What it's for |
|---|---|
app | The background behind everything |
panel | A large region on the app background, such as an inspector |
section | A quiet well that groups cards |
card | Content on a page or in a section |
raised | A card that's lifted, such as a selected item |
floating | Menus, popovers and toolbars that float over the page |
dialog | Dialogs, over a scrim |
inset | A sunken field inside a card |
Give Surface its level with level, which is "card" by default:
import type { ReactElement } from "react";
import { Surface, Text } from "@butteryui/core";
export function MenuPanel(): ReactElement {
return (
<Surface level="floating" pad={3}>
<Text variant="menu">Duplicate</Text>
</Surface>
);
}Floating menu
The floating level used by menus and popovers, holding a short list.
In dark mode, surfaces get lighter as they rise instead of casting stronger shadows, which can't be seen on a dark background. The same levels in both:
light
dark
Shadows
The shadows behind the levels, and the rings for selection and focus: