prongs
GitHub

Layout

Page regions and groups. The intent decides the element (<main>, <section>, <form>, <ul>, <li>) and the arrangement.

Renders

mainheaderdiv

Intents

Domains

Examples

A form

layout.form renders the <form>, layout.field groups each field, layout.actions holds the buttons.

Preview
<Layout intent="layout.form" className="w-full max-w-sm">
<Layout intent="layout.field">
<Text intent="text.label" as="label" htmlFor="example-name">Name</Text>
<Field intent="field.text" id="example-name" />
</Layout>
<Layout intent="layout.actions">
<Action intent="action.save">Save</Action>
</Layout>
</Layout>

A list

layout.list renders a <ul> and layout.item its <li>s.

Preview
  • Design review

    Tomorrow, 10:00
  • Release planning

    Friday, 14:30
<Layout intent="layout.list" className="w-full">
<Layout intent="layout.item">
<Text intent="heading.item">Design review</Text>
<Text intent="text.meta">Tomorrow, 10:00</Text>
</Layout>
<Layout intent="layout.item">
<Text intent="heading.item">Release planning</Text>
<Text intent="text.meta">Friday, 14:30</Text>
</Layout>
</Layout>

A box about one thing

A box with its own surface is an intent too, not a class.

Preview

Two-step sign-in

Ask for a code from your phone as well as your password.

<Layout intent="layout.panel" className="w-full max-w-sm">
<Text intent="heading.item">Two-step sign-in</Text>
<Text intent="text.body">Ask for a code from your phone as well as your password.</Text>
<Layout intent="layout.actions">
<Action intent="action.start">Turn on</Action>
</Layout>
</Layout>

A notice

A message about the page, with a way to dismiss it.

Preview

Check your email to confirm your address.

<Layout intent="layout.notice" className="w-full">
<Text intent="feedback.info">Check your email to confirm your address.</Text>
<Action intent="action.dismiss" icon={<X aria-hidden className="size-4" />} label="Dismiss" />
</Layout>

Intents it renders

One domain, with its own page of neighbours and examples. The intent decides the element; these are the starter intents.

Layout layout.*

42 intents
  • layout.page

    A centred column of content. An app page has one; a marketing page may have one per full-width band

    <main>
  • layout.task

    A page for one short task or one message, centred on the screen: sign in, reset password, a confirmation, not found, a link that has expired. Its headings, text and actions are centred; a form or section inside takes the full width

    <main>
  • layout.header

    The bar at the top of the site or app: the product name, its navigation and account controls

    <header>
  • layout.shell

    The frame of an app with a sidebar: one layout.aside beside the main column. Used once, around the signed-in part of the app

    <div>
  • layout.aside

    Content beside the main column: a docs sidebar, filters, a table of contents

    <aside>
  • layout.footer

    The site footer at the bottom of every page

    <footer>
  • layout.section

    A part of a page made of separate blocks, with or without a title: a section under its heading, the cards in a column, a panel’s contents

    <section>
  • layout.screen

    A whole screen with its own background, like a maintenance, sign-in or error page. It takes the page colours, so the page is not the app’s background

    <main>
  • layout.anchor

    A plain box with no look that positions what sits inside it: the anchor for a badge or a menu placed over an element

    <div>
  • layout.group

    A few closely related elements kept together, e.g. a heading and its text

    <div>
  • layout.headline

    Content at the start of a line and its controls at the end: a section’s title and its button, a panel’s title bar, a list entry with its actions. The controls drop below when the line runs out of room

    <div>
  • layout.intro

    The heading and short text that introduce a section, above its content: a section title and its lead, a block of cards’ introduction

    <div>
  • layout.split

    Two parts of one section side by side that stack on phones: an image beside its text, a form beside a preview. data-reverse puts the second part first on wider screens

    <div>
  • layout.lockup

    An icon, avatar or logo beside its text: a person’s photo and name, an icon and its label. The text shrinks and wraps; the icon keeps its size

    <div>
  • layout.form

    A form: renders <form> and stacks its fields

    <form>
  • layout.field

    One form field: its label, input, help text and error

    <div>
  • layout.actions

    Commands side by side: a form’s buttons, a dialog’s choices

    <div>
  • layout.toolbar

    Controls that act on the content below them: filters, views, refresh

    <div>
  • layout.details

    Label and value pairs about one thing: an order’s totals, a booking’s What / When / Who, a record’s details. Renders <dl>; each pair is a <div> with a text.label as="dt" and its value as="dd"

    <dl>
  • layout.table

    Records with the same fields, compared across: members, invoices, API keys. Write plain thead, tbody, tr, th scope="col" and td inside, with no classes; data-off on a tr marks a row that is switched off. Use data-head="bar" when the table runs edge to edge in a panel with no padding. With more columns than fit on a phone, wrap it in a layout.scroller

    <table>
  • layout.scroller

    Content wider than its column, which the reader scrolls sideways: a table with many columns, a long line of code, a board. Give it tabIndex={0} and an aria-label, so keyboard users can scroll it too

    <div>
  • layout.pager

    The row of nav.paging links below a long list or table. Give it aria-label="Pagination"

    <nav>
  • layout.dock

    A bar that stays at the bottom of the screen while the content under it scrolls or changes: the now-playing bar, a cart total, a long form’s submit button on phones

    <footer>
  • layout.list

    A list of items of the same kind: articles, people, notifications. Children are layout.item

    <ul>
  • layout.item

    One entry in a layout.list

    <li>
  • layout.panel

    A self-contained box about one thing: a sign-in box, a profile summary

    <div>
  • layout.collection

    Equal items shown side by side as a grid: people to follow, featured sources. It fits as many columns as its own width allows, so it works in a sidebar as well as across a page; set columns from a breakpoint only when the count matters

    <div>
  • layout.notice

    A message about the page or the account: check your email, password updated, your trial ends soon. Add an action.dismiss when it can be dismissed

    <div>
  • layout.toast

    A short message that appears over the page and leaves on its own, sometimes with one action: saved, could not send, undo. Holds one feedback.* line and at most one action

    <div>
  • layout.empty

    What a region shows when it has nothing yet: an icon, a heading, a sentence and the first action

    <div>
  • layout.loading

    Stands in for content that is still loading: a full-width line of text unless you give it the shape of what will appear

    <div>
  • layout.divider

    A break between two parts of the same content: groups in a menu, sections of a panel. Runs across whichever way its parent flows

    <hr>
  • layout.disclosure

    Content that opens and closes in place under a text.summary line: an FAQ answer, advanced settings

    <details>
  • layout.subnav

    A page with its own section nav beside its content: settings, account, a project’s admin. Put the nav first (a nav of nav.page links), then the content. On phones the nav sits above it

    <div>
  • layout.article

    A reading column for a whole page: articles, documents, settings

    <main>
  • layout.teaser

    A box in a layout.collection that previews one page and opens it as a whole: its nav.item title covers the box

    <div>
  • layout.band

    A full-width part of a marketing page with its content centred: a hero, a row of features, a call to action. Put a layout.page inside for the content width

    <section>
  • layout.chart

    A chart: a trend over time, a breakdown. Renders <figure>; put the chart's svg or canvas inside with a height, and a text.caption that says what it shows

    <figure>
  • layout.blocks

    An amount shown as a row of blocks, like a battery: the more blocks filled, the more of it. Each block is a layout.blocks.cell, with data-on on the filled ones; data-tone="success", "warning" or "danger" on the row colours them by level. Give it aria-valuenow, aria-valuemin and aria-valuemax

    <div>
  • layout.blocks.cell

    One block of a layout.blocks; data-on when it is filled

    <div>
  • layout.badged

    An icon or avatar with a status dot on its corner: a device and whether it is online. Put the icon first and a text.indicator last

    <div>
  • layout.overlay

    Controls placed over a photo or video, like the arrows in a dialog.media, kept readable on any image

    <div>

Props

Plus its element’s usual attributes (id, onClick, aria-*, data-*). className is for layout only.

  • intent required

    What this region is: layout.page, layout.form, layout.list...

    LayoutIntent
  • className

    Layout and spacing only: margins, sizes, flex and grid, gaps, padding, text alignment. Visual classes warn in development and fail prongs check.

    string
  • hideBelow

    Hidden on screens narrower than this breakpoint: the desktop half of a region built twice.

    'sm' | 'md' | 'lg'
  • showBelow

    Shown only on screens narrower than this breakpoint: the phone half.

    'sm' | 'md' | 'lg'
  • align

    Pushes the region to that end of its row or column, like a group of controls at the end of a header.

    'start' | 'center' | 'end'
  • ref

    Reaches the rendered element.

    Ref<HTMLElement>
  • unsafeClassName

    Bypasses the intent. Needs a // prongs-unsafe: <reason> comment on the line above, and prongs check counts it.

    string

Rules

  • The only component with a className, and only for layout.

  • Hide or show by screen size with hideBelow and showBelow, and push a region to one end with align, rather than classes.

  • A box that needs its own background or border is a different intent (layout.panel, layout.notice), not a class.

  • Pass onSubmit to a layout.form.