StartFoundationsComponentsContent

Sheet layout

A sheet layout lets a side sheet open next to the content instead of over it, when there's room. When there isn't, the sheet opens as a modal.

Stable
OverviewUsageAPIAccessibility
View deployment

Make the window narrower: the sheet stops sitting beside this text and opens over it.

Built from main 2 minutes ago.

Done
<tk-sheet-layout content-min="240" style="--tk-sheet-size: 280px; min-block-size: calc(var(--space-96) * 3);">
  <div>
    <tk-button onclick="document.getElementById('deployment').show()">View deployment</tk-button>
    <p>Make the window narrower: the sheet stops sitting beside this text and opens over it.</p>
  </div>
  <tk-sheet id="deployment" heading="Deployment" side="right">
    <p>Built from main 2 minutes ago.</p>
    <tk-button slot="footer" onclick="this.closest('tk-sheet').close()">Done</tk-button>
  </tk-sheet>
</tk-sheet-layout>

How it works

<tk-sheet-layout content-min="640">
  <main>
    <tk-button onclick="document.getElementById('deployment').show()">View deployment</tk-button>
  </main>
  <tk-sheet id="deployment" heading="Deployment" side="right">
    <p>Built from main 2 minutes ago.</p>
  </tk-sheet>
</tk-sheet-layout>
  • Put the page content and a left or right Sheet inside the layout.
  • When the layout is at least content-min wide plus the sheet's width, the sheet docks: it opens as a column beside the content, and the content narrows. Nothing is covered, and the page stays usable.
  • When it isn't that wide, the sheet opens as a modal over the page.
  • If the width changes while the sheet is open, it switches in place. What someone typed, where they scrolled and where focus was all stay.
  • The sheet's mode tells you which one it is: docked or modal.

Placing the sheet

  • Put a left sheet before the content and a right sheet after it, so the Tab order matches what people see.
  • A docked sheet stays space-8 (8px) away from the edges of its column and stays in view while the page scrolls.
  • top and bottom sheets never dock. They open as a modal.
  • To change the width, set --tk-sheet-size on the sheet. The layout counts it when it decides whether there's room.