App frame

An application stands in one frame, edge to edge in the window. A bar two squares high runs along the top with the app’s name, what the app puts after it (a breadcrumb, tabs, a search) and its actions at the end. Under it the navigation, the work and an inspector stand side by side, each scrolling on its own, with a hairline between them. On desktop, the navigation starts directly below the bar. In the Docs example, its divider continues through the bar. The navigation and the inspector are resized by dragging the line between them and the work, in whole squares, and the widths are remembered for the app. Open the full-window example and resize the window to see it hold.

Grid
An application in its frame

The bar, the navigation, the work and an inspector. Drag a line beside a pane, or focus it and use the arrow keys: the pane moves in whole squares.

<code><span class="line"><span style="color:var(--docs-code-ink)"><</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-keyword)"> name</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Notes"</span><span style="color:var(--docs-code-keyword)"> home</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"/"</span><span style="color:var(--docs-code-keyword)"> resize-key</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"notes"</span><span style="color:var(--docs-code-keyword)"> grid-anchor</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"top"</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">nav</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"bar"</span><span style="color:var(--docs-code-keyword)"> aria-label</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Breadcrumb"</span><span style="color:var(--docs-code-ink)">>Workspace / Meeting notes</</span><span style="color:var(--docs-code-tag)">nav</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">div</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"actions"</span><span style="color:var(--docs-code-ink)">><</span><span style="color:var(--docs-code-tag)">ds-button</span><span style="color:var(--docs-code-ink)">>Share</</span><span style="color:var(--docs-code-tag)">ds-button</span><span style="color:var(--docs-code-ink)">></</span><span style="color:var(--docs-code-tag)">div</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"nav"</span><span style="color:var(--docs-code-keyword)"> label</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Notebooks"</span><span style="color:var(--docs-code-ink)">></</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">article</span><span style="color:var(--docs-code-ink)">>…the work…</</span><span style="color:var(--docs-code-tag)">article</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">section</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"aside"</span><span style="color:var(--docs-code-keyword)"> aria-label</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Properties"</span><span style="color:var(--docs-code-ink)">>…</</span><span style="color:var(--docs-code-tag)">section</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"></</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-ink)">></span></span></code>

Start the scale first, in the page’s first module, before anything else draws, so the first paint is already on whole squares. ds-app starts it too, but an app that starts it itself never draws a frame at another scale first:

<code><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-ink)"> { startAppScale } </span><span style="color:var(--docs-code-keyword)">from</span><span style="color:var(--docs-code-string)"> "@0001-labs/design-system-1/ds1/4-page/app-scale"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"><span style="color:var(--docs-code-tag)">startAppScale</span><span style="color:var(--docs-code-ink)">({ anchor: </span><span style="color:var(--docs-code-string)">"top"</span><span style="color:var(--docs-code-ink)"> });</span></span></code>

The package exports its source, ds1/*, as written: modules are imported without their .ts ending, so a Vite app resolves the folder itself and TypeScript finds it the same way, and the package stays out of Vite’s prebundling so the frame’s styles load as the components ask for them:

vite.config.ts
<code><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-ink)"> { fileURLToPath } </span><span style="color:var(--docs-code-keyword)">from</span><span style="color:var(--docs-code-string)"> "node:url"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"><span style="color:var(--docs-code-keyword)">export</span><span style="color:var(--docs-code-keyword)"> default</span><span style="color:var(--docs-code-ink)"> {</span></span><span class="line"><span style="color:var(--docs-code-ink)">  resolve: { alias: [{ find: </span><span style="color:var(--docs-code-string)">"@0001-labs/design-system-1/DS1"</span><span style="color:var(--docs-code-ink)">, replacement: </span><span style="color:var(--docs-code-tag)">fileURLToPath</span><span style="color:var(--docs-code-ink)">(</span><span style="color:var(--docs-code-keyword)">new</span><span style="color:var(--docs-code-tag)"> URL</span><span style="color:var(--docs-code-ink)">(</span><span style="color:var(--docs-code-string)">"./node_modules/@0001-labs/design-system-1/DS1"</span><span style="color:var(--docs-code-ink)">, </span><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-ink)">.meta.url)) }] },</span></span><span class="line"><span style="color:var(--docs-code-ink)">  optimizeDeps: { exclude: [</span><span style="color:var(--docs-code-string)">"@0001-labs/design-system-1"</span><span style="color:var(--docs-code-ink)">] },</span></span><span class="line"><span style="color:var(--docs-code-ink)">};</span></span></code>
<code><span class="line"><span style="color:var(--docs-code-comment)">// tsconfig.json, under compilerOptions</span></span><span class="line"><span style="color:var(--docs-code-string)">"paths"</span><span style="color:var(--docs-code-ink)">: { </span><span style="color:var(--docs-code-keyword)">"@0001-labs/design-system-1/ds1/*"</span><span style="color:var(--docs-code-ink)">: [</span><span style="color:var(--docs-code-string)">"./node_modules/@0001-labs/design-system-1/ds1/*"</span><span style="color:var(--docs-code-ink)">] }</span></span></code>

one.css (through grid.css) draws the frame before its script has run: the window, the bar’s paper and hairline, and what it holds out of sight, so the first paint is already the frame. await app.updateComplete settles once the frame and the page under its bar have both drawn, when everything slotted stands in its place and can be measured.

The frame is a Page in the inspector layout under a bar, so its areas are the page’s five and the bar’s three. An area with nothing in it takes no room: an app without navigation or an inspector gives the work the window.

AreaPut it there withHolds
Brandslot="brand"The app’s mark or name, a link home. Without it, name is drawn as a link to home.
Barslot="bar"What follows the name: a breadcrumb, tabs or a search.
Actionsslot="actions"Buttons and the account, at the bar’s end; on a phone, in the drawer under the navigation.
Navigationslot="nav"The app’s places, usually one Sidebar, which takes the pane’s width.
Headerslot="header"The work’s title and its own actions, above it.
WorkNo slotThe work itself, the document’s main landmark unless it is given a <main>.
Inspectorslot="aside"Properties or settings of what is selected.
Footerslot="footer"Closing actions, below the work.

The frame stands on Desktop aligned: on a computer the scale moves slightly so the window is a whole number of squares wide, and the first row starts at the top edge. The bar takes two whole squares. Any partial row falls at the bottom. The shared components follow the same scale, so controls, panes and type grow and shrink together. A phone keeps its fourteen squares across. Set grid-anchor="bottom" to put the partial row at the top instead. Set the same anchor in the early startup call when the page starts the scale before the frame connects.

Two scales must not run at once. Remove a page’s own startScaling() when it moves into the frame, and any pin such as --ds-sf: 1 that holds the components at another scale. The root carries data-ds-scaling-managed, so the device module reads the frame’s scale instead of putting its own. fixed-scale leaves the scale to the page altogether, for a frame drawn inside something that sets its own.

The navigation and the inspector are twelve squares wide by default, and four to twenty-four squares as they are resized, always leaving ten squares for the work. Drag the line beside a pane: the pane follows the pointer and snaps to a whole square on release. Each divider is a slider for the keyboard: the arrow keys move it one square, five with Shift, Home and End to either limit, and Enter or a double press goes back to the default. Escape cancels a drag. ds-page-resize reports the new widths in detail.navWidth and detail.asideWidth.

A width is what stands in the pane: a twelve-square navigation holds a sidebar exactly twelve squares wide. The pane’s own box reaches half the gap further, to the hairline in the middle of the two squares between it and the work, so measured from the outside it is one square wider than its width.

Widths are remembered in this browser under resize-key, or ds-app: and the app’s name when there is none, so every page of an app opens with the panes as they were left. Storage is optional: resizing works without it.

Below thirty squares of width the frame is one document scrolling under the bar. The navigation and the actions fold away, so the bar keeps only the name, what follows it and a menu button in its last square, and nothing in it is ever cut off. The menu button opens them over the screen, the actions under the navigation, the screen overlay with its close button where the menu button stood and the navigation from the square under the bar. Focus stays inside it, and Escape, the close button, a link or the window widening close it. The inspector stands under the work. openDrawer() and closeDrawer() work the drawer from code, and ds-page-drawer reports it opening and closing in detail.open.

With flush, the work leaves out the square of room around it and runs to the hairlines beside it, the bar above and the window’s bottom edge (or to the window’s sides where there is no pane). The navigation and the inspector keep their square of room and their widths, and a header or footer keeps its distance from the work.

With flow, the page is the document: the window scrolls it, and the bar stays at the top with its hairline on the grid. Use it for a site, or for an app whose pages already scroll with the window, where the scroll position, the browser’s scroll restoration and anything that reads window.scrollY must keep working. The panes then take their content’s height instead of the window’s, and scrollToStart() scrolls the window. Before its script runs, a flowing frame draws its page at once under the bar’s room, so the first paint is the content and nothing jumps.

An app that changes its work in place, as a router does, calls scrollToStart() when a new place opens: the work goes back to its top, its own pane on a computer and the page on a phone.

Overlays, menus and toasts open in the browser’s top layer, above the frame, as they do on any page.

A family of apps that should lead to one another gives each frame the same apps: a list of { name, href }, as a property or a JSON attribute. Hovering the name, focusing it with the keyboard or tapping it on a phone opens the list under the bar, hanging from its hairline, with the app that is open marked; leaving it or pressing Escape closes it. The name still leads home with a click. The list is the family’s own, kept in one place they all import; the frame holds no names of its own.

<code><span class="line"><span style="color:var(--docs-code-ink)">document.</span><span style="color:var(--docs-code-tag)">querySelector</span><span style="color:var(--docs-code-ink)">(</span><span style="color:var(--docs-code-string)">'ds-app'</span><span style="color:var(--docs-code-ink)">).apps </span><span style="color:var(--docs-code-keyword)">=</span><span style="color:var(--docs-code-ink)"> [</span></span><span class="line"><span style="color:var(--docs-code-ink)">  { name: </span><span style="color:var(--docs-code-string)">'Notes'</span><span style="color:var(--docs-code-ink)">, href: </span><span style="color:var(--docs-code-string)">'https://notes.example.com/'</span><span style="color:var(--docs-code-ink)"> },</span></span><span class="line"><span style="color:var(--docs-code-ink)">  { name: </span><span style="color:var(--docs-code-string)">'Photos'</span><span style="color:var(--docs-code-ink)">, href: </span><span style="color:var(--docs-code-string)">'https://photos.example.com/'</span><span style="color:var(--docs-code-ink)"> },</span></span><span class="line"><span style="color:var(--docs-code-ink)">];</span></span></code>
AttributeDefaultWhat it does
name—The app’s name, drawn at the bar’s start when there is no brand.
home/Where the name leads.
layoutinspectorThe page’s layout under the bar; inspector holds navigation, work and inspector, each optional.
nav-width12The navigation’s width in whole squares, 4 to 24.
aside-width12The inspector’s width in whole squares, 4 to 24.
resize-keyds-app: and the nameWhere the widths are remembered.
drawer-labelMenuThe menu button’s and drawer’s name, a translation key.
grid-anchortopThe edge where the desktop grid starts. bottom moves the partial row above the frame.
fixed-scalefalseLeaves the scale to the page: the frame starts no scale of its own.
flushfalseThe work runs to its pane’s edges, for a wall of pictures or a canvas; the navigation and the inspector keep their room.
flowfalseThe page is the document: the window scrolls it under a bar that stays at the top.
appsnoneThe apps the name leads to, { name, href }[]; see Between apps.
PartWhat it is
barThe top bar.
brandThe name’s link.
switchThe name and its apps, with apps.
appsThe list of apps under the name.
actionsThe actions’ place at the bar’s end, on a computer.
menuThe phone’s menu button at the bar’s end.
pageThe page under the bar, a ds-page.

The page’s own parts are passed on under the same names: nav, header, main, aside, footer, drawer, resize and resize-aside, so ds-app::part(main) reaches the work’s pane.

page on the element is that ds-page, for its widths and its drawer.

NameWhat it does
openDrawer(), closeDrawer()Open or close the navigation’s drawer on a phone.
scrollToStart()Takes the work back to its top.
updateCompleteSettles when the frame and its page have drawn.
ds-page-resizeA divider moved: detail.navWidth, detail.asideWidth.
ds-page-drawerThe drawer opened or closed: detail.open.

An area whose content is all hidden takes no room, so an inspector opens and closes by toggling hidden on it. Enter or a double press on a divider goes back to the width the frame was given (nav-width, aside-width), not to a remembered one.

React uses the element directly. Import 4-page/ds-app once in the browser entry; ds-sidebar and other components register through their own imports.

<code><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-string)"> "@0001-labs/design-system-1/ds1/4-page/ds-app"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"><span style="color:var(--docs-code-keyword)">import</span><span style="color:var(--docs-code-string)"> "@0001-labs/design-system-1/ds1/3-unit/ds-sidebar"</span><span style="color:var(--docs-code-ink)">;</span></span><span class="line"></span><span class="line"><span style="color:var(--docs-code-ink)"><</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-keyword)"> name=</span><span style="color:var(--docs-code-string)">"Notes"</span><span style="color:var(--docs-code-keyword)"> resize-key=</span><span style="color:var(--docs-code-string)">"notes"</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-keyword)"> slot=</span><span style="color:var(--docs-code-string)">"nav"</span><span style="color:var(--docs-code-keyword)"> label=</span><span style="color:var(--docs-code-string)">"Notebooks"</span><span style="color:var(--docs-code-keyword)"> items=</span><span style="color:var(--docs-code-ink)">{notebooks} /></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">Editor</span><span style="color:var(--docs-code-ink)"> /></span></span><span class="line"><span style="color:var(--docs-code-ink)"></</span><span style="color:var(--docs-code-tag)">ds-app</span><span style="color:var(--docs-code-ink)">></span></span></code>

Page · Scaling · Sidebar · Overlay · Header