Skip to content
buttery

v1.0.0

Source on GitHub

Version 1.0.0

Radius

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

The radius scale names the corner radii buttery uses, from xs (6px) to full, and a few named for the part they round, such as kbd (5px) for keycaps. Use a radius token for every rounded corner, and let nested surfaces work out their own.

--bt-r-xs 路 6px
--bt-r-kbd 路 5px
--bt-r-thumb 路 7px
--bt-r-sm 路 8px
--bt-r-md 路 10px
--bt-r-lg 路 12px
--bt-r-xl 路 14px
--bt-r-2xl 路 16px
--bt-r-3xl 路 16px
--bt-r-dialog 路 18px
--bt-r-full 路 9999px

Use a radius token

Each radius is a CSS variable, --bt-r-<name>. Read it with var(), never a length of your own:

Do

css

.tile {
  border-radius: var(--bt-r-lg);
}

A radius from the scale, which follows the theme when createTheme's radius makes corners rounder or tighter.

Don't

css

.tile {
  border-radius: 11px;
}

A radius off the scale, which won't nest and fails buttery's stylelint config.

Concentric corners

A card inside a panel looks right when its corners follow the panel's: the inner radius is the outer radius less the padding between them. Surface does this for you with radius="auto", never going below 4px.

tsx

import type { ReactElement } from "react";
import { Surface, Text } from "@butteryui/core";

export function SettingsGroup(): ReactElement {
  return (
    <Surface level="section" pad={2}>
      <Surface level="card" radius="auto" pad={4}>
        <Text variant="body">Notifications</Text>
      </Surface>
    </Surface>
  );
}

Nested section

A panel holding a section whose card nests with concentric corners.

Background
Fill
  • Elevation

    Surface levels, from the app's background to dialogs, and the shadows that set them apart.

  • Surface and nesting

    How surfaces nest, with concentric corners and even insets, and the Surface primitive that does it.