Skip to content
buttery

v1.0.0

Source on GitHub

Version 1.0.0

Check your layout

Catching overlaps, overflow and layout shift while you work and in your tests.

buttery checks layout in three places: LayoutGuard while you work, buttery check on the running app, and expectButtery in your tests. Use them together, so a layout problem shows up the moment you make it and can't come back once it's fixed.

While you work

In a Vite development build, ButteryProvider turns on LayoutGuard. It outlines in red anything that breaks a layout rule, such as an overlap, an overflow or a space off the scale, and logs each problem to the console as [buttery:LayoutGuard] with how to fix it.

ShortcutWhat it does
⌥⇧L (Option+Shift+L, or Alt+Shift+L off a Mac)Hides and shows the outlines
⌥⇧GShows and hides the 12-column page grid

Production builds never include it, and layoutGuard={false} on ButteryProvider leaves it out in development too.

Resize as you go. Narrow the window from wide to a phone's width as you work: most layout problems only show at some widths.

On the running app

bash

npx buttery check / /settings

buttery check runs the checks expectButtery runs on each page you name, at 390 and 1280 wide, light and dark, starting the app's dev server when it isn't running. --full checks every width, both densities and WebKit too. Command line has its options.

In your tests

expectButtery runs the same checks and more in Playwright, at every width, theme and density you give it. Start with quickMatrix in every test, and run fullMatrix before a release. Testing has its options and every check it runs.

Reading a report

A failed check prints each problem with its rule, the element as a selector, what it measured and a fix:

text

buttery found 1 layout problem:

✗ orders at 390x844, light, comfortable, chromium
  overflow      html: the page scrolls sideways by 51px
                Fix: Something is wider than the viewport; fix the overflow violations above, or let the widest element shrink.

buttery check --json prints the problems it finds as JSON, for a script or a coding agent to work through, as pnpm test:layout --reporter=json does in buttery's own repository.

Fix the cause, not the symptom. A component that overflows needs room, or min-width: 0 so it can shrink, never a hidden overflow. Stack, Inline and Grid give every child min-width: 0, so lay it out in one of them, or give it a column of its own in a Grid.

  • Command line

    buttery's command line starts an app from a template, adds pages and components to it, checks its layout, and sets buttery up in an app you have.

  • Testing

    expectButtery, the Playwright check that fails a page that overlaps, overflows or shifts, at every size you ask for.

  • The layout contract

    The 13 rules every buttery screen follows, so nothing overlaps, overflows or shifts, and how they're checked.

  • Make an existing app buttery

    Bringing buttery into an app that already has its own styles and components, a screen at a time.