Skip to content
buttery

v1.0.0

Source on GitHub

Version 1.0.0

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:

LevelWhat it's for
appThe background behind everything
panelA large region on the app background, such as an inspector
sectionA quiet well that groups cards
cardContent on a page or in a section
raisedA card that's lifted, such as a selected item
floatingMenus, popovers and toolbars that float over the page
dialogDialogs, over a scrim
insetA sunken field inside a card

Give Surface its level with level, which is "card" by default:

tsx

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.

WideSquareTall

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

panelbg #ffffff 路 shadow-card 路 r 16
sectionbg #f7f7f7 路 edge #ebebeb 路 r 16
cardbg #ffffff 路 shadow-card 路 r 12
raisedbg #ffffff 路 shadow-raised 路 r 12
floatingbg #ffffff 路 shadow-floating 路 r 16
dialogbg #ffffff 路 shadow-dialog 路 r 18
insetbg #fefefe 路 edge #e3e3e3 路 r 10
Section
Card row
Card row

dark

panelbg #19191b 路 shadow-card 路 r 16
sectionbg #141416 路 edge #2a2a2e 路 r 16
cardbg #19191b 路 shadow-card 路 r 12
raisedbg #2c2c30 路 shadow-raised 路 r 12
floatingbg #1f1f22 路 shadow-floating 路 r 16
dialogbg #19191b 路 shadow-dialog 路 r 18
insetbg #161618 路 edge #333338 路 r 10
Section
Card row
Card row

Shadows

The shadows behind the levels, and the rings for selection and focus:

--bt-shadow-card
--bt-shadow-raised
--bt-shadow-selected
--bt-shadow-knob
--bt-shadow-floating
--bt-shadow-dialog
--bt-shadow-inset
--bt-ring-select
--bt-ring-focus
  • Radius

    The corner radius scale, and how nested surfaces keep their corners concentric.

  • Layers

    The z bands menus, dialogs, toasts and tooltips open into, and the primitives that put things in them.