Make anything buttery
The four ways to bring buttery into an app, from wiring up the provider to whole-page patterns.
There are four levels of effort for making an app buttery, numbered 0 to 3, and each adds to the one before. Start at the first and stop wherever the app feels right: nothing at a higher level is required.
The four levels
Wire it up
Import the stylesheets once at the entry and wrap the app in
ButteryProvider:import "@butteryui/core/styles.css"; import "@butteryui/react/styles.css"; import type { ReactElement } from "react"; import { ButteryProvider } from "@butteryui/react"; import { App } from "./App.tsx"; export function Root(): ReactElement { return ( <ButteryProvider> <App /> </ButteryProvider> ); }That alone gives the whole app the tokens, Inter, focus rings, the selection color and scrollbars in light and dark, the layers and lanes that menus and toasts open into, motion presets that follow reduced motion, and
LayoutGuardin development.Wrap what you have
The
butteryfactory turns any element or component into a buttery one, with token-typed props for its surface, padding, gap, press feedback and entrance:import type { ReactElement } from "react"; import { buttery } from "@butteryui/react"; export function Receipt(): ReactElement { return ( <buttery.div surface="card" pad={4} stack gap={3} enter="rise"> Order 1042 is on its way. </buttery.div> ); }buttery(Component, { surface: "raised", hover: "lift" })does the same for a component from another library. Plain HTML can use the recipes as classes and attributes, such asclass="bt-surface" data-level="card".Compose components
Build screens from buttery's components and primitives, as the quick start does:
Stack,InlineandGridfor layout, and controls such asButton,SliderandSegmentedControlthat already follow the layout and motion rules. All components lists every one by the job it does.Start from a pattern
Patterns are whole screens that already follow the rules, and templates are whole apps made from them:
An app
AppShellwithSidebar,TopBarandAppPage, the App shell pattern, or the dashboard template.A marketing page
Pagewith a hero, a bento grid and a footer, the Marketing page pattern, or the marketing template.
Where to start
| If your app is… | Start at |
|---|---|
| New | Level 3: copy a template with pnpm new-app my-app --template dashboard, and change what it shows |
| Built, and you'd like it to look and move better | Level 0, then level 1 for its parts, one screen at a time |
| Built with another component library | Level 1: wrap its components with buttery(), and swap them for buttery's as you touch each screen |
Make an existing app buttery walks through bringing a working app across, one screen at a time.
Related
- Quick start
A first screen on buttery, from an empty starter to a checked layout, in about ten minutes.
- Make an existing app buttery
Bringing buttery into an app that already has its own styles and components, a screen at a time.
- The layout contract
The 13 rules every buttery screen follows, so nothing overlaps, overflows or shifts, and how they're checked.