AddThisFeature

Drawer Layout Pattern

Use one side panel pattern for secondary work so the page underneath is never lost.

involved Components & Primitives

What it adds

A side panel with agreed widths, its own scroll region, its own URL, and defined behaviour on narrow screens.

What your agent is told to do

5
  1. 1

    Find the places the app currently pushes the user to a separate page for secondary work — editing a record from a list, viewing details, filters, a settings sub-section — and decide which of those belong in a drawer beside the context rather than instead of it.

  2. 2

    Give the drawer its own address so the state can be linked, refreshed, and reached from a notification, and so the browser's back button closes it rather than leaving the page altogether.

  3. 3

    Keep the drawer's scroll region separate from the page's, and preserve the page's scroll position so closing the drawer returns the user to exactly the row they opened it from.

  4. 4

    Define two or three widths and a side, and apply them consistently. A drawer that is 400 pixels on one screen and 640 on the next reads as two different components.

  5. 5

    Background scroll locking belongs to the Scroll Containment Utility and focus handling belongs to the Focus Containment Primitive. Consume both here rather than writing panel-specific versions.

Edge cases it handles

7
  • Below the mobile breakpoint a side drawer leaves a useless sliver of page behind it. Switch to a full-screen or bottom-sheet presentation at a defined width, and make the close control obvious in that mode.
  • The drawer and the page must scroll independently, and reaching the end of the drawer's content must not start scrolling the list behind it.
  • A drawer opened directly from a link must render correctly with no page state behind it, and the back button must close the drawer and reveal the underlying view rather than navigating out of the app.
  • Drawers that open further drawers quickly leave nothing of the original context visible and no clear way back. Either forbid nesting and replace the drawer's content in place with a back control, or cap it at one level.
  • Unsaved edits in a drawer must be guarded before it closes, including when it is closed by the backdrop, by Escape, or by the back button.
  • Opening a drawer must not resize or reflow the page behind it, or every row the user was reading moves at the moment they click.
  • The record the drawer is showing may be deleted or edited by someone else while it is open; the drawer needs its own error and removed states rather than closing without explanation.

Definition of done

9
  • Every side panel in the app uses the one pattern, with a defined side and one of the agreed widths.
  • The drawer has its own URL and restores correctly when that URL is opened directly.
  • The back button closes the drawer and leaves the user on the underlying page.
  • Drawer and page scroll independently, and the page's scroll position is unchanged on close.
  • Narrow screens present the drawer full-screen with an obvious close control.
  • Nesting is either prevented or capped, with a clear route back to the previous content.
  • Scroll locking and focus handling are delegated to the shared primitives.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.