app-shell
The frame of an app: places, bar and content, and which of them scrolls.
When an agent loads it
Builds the frame of an app: where the places to go, the bar with the title and the content sit, which of them scrolls, and how the frame changes between a phone and a tablet or desktop. Ships tested base CSS and markup to copy instead of deriving a layout from scratch. Use when starting an app, a dashboard or an admin tool, when adding a sidebar, a top bar or a bottom tab bar, when a layout has two scrollbars, a sidebar that scrolls away, content under a bar, a page that scrolls sideways or jumps on a phone, or when the user says a layout looks or feels wrong.
The base code, running
The same file in two windows, as the skill ships it: assets/page.html. Scroll each and follow its links. Open it on its own to use it with the browser's Back.
Install
npx skills add simon-lund/skills --skill app-shell The skills CLI puts it where your agent reads
skills: Claude Code, Codex, Cursor and the others it knows. npx skills update brings
in a later version.
Clone the repository:
git clone https://github.com/simon-lund/skills.gitCopy the skill's folder to where your agent reads skills. For Claude Code:
cp -r skills/skills/app-shell ~/.claude/skills/The folder holds 5 files:
SKILL.md,assets/app-shell.css,assets/page.html,assets/workspace.html,references/traps.md.
Why it exists
The frame is the same in almost every app: places to go, a bar with the title, the content. It is written down only in pieces, so an agent derives it anew each time and gets one of a dozen known details wrong. Each shows only at some width, with some length of content or on a real phone, which is why it passes a quick look.
This skill doesn't derive the frame. It decides three things (what scrolls, the places, the title), copies a base that is tested at phone and desktop width, and keeps every line that guards against one of those faults.
Where it came from
12 November 2026. I asked for the patterns that are standard and that nobody has written down in one place, with the base code, so I don't have to deal with a wrong layout just because the agent didn't know what to do. The frame is the first, because every other part stands on it.
Don't let the window and the content both scroll. The wheel moves one, then the other, and the bar leaves with the page.
Do decide which one scrolls: the page, or one part of a window that stays put.
Some of its lines come from moments I had already paid for:
- 31 October 2026: the place I was in showed as a slightly lighter grey. Where you are has to be clear at a glance.
- 1 November 2026: a bottom sheet was invented where Material already had the anatomy and the measurements. The platform's pattern comes first.
- 11 November 2026: a picture with a set width ran past its grid column. A column of
1frdoesn't hold its content back;minmax(0, 1fr)does.
The rules behind it
Regular: tablets and up. Tablet portrait goes with regular, as two panes.
Do use the platform's patterns before inventing one. A pattern of my own needs a written reason. (Jakob's law: people expect your product to work like the ones they already know.)
Measure, don't eyeball. Centre optically by the weight of the text, not its box. Keep radii concentric (outer = inner + gap). Line baselines up across columns.
Every fix becomes a rule or a token, so the next thing gets it for free.
Check light and dark, the longest string of every language, the smallest and largest size.
How to tell it works
- Before any markup it says whether the screen is a page or a workspace, and why.
- Exactly one thing scrolls up and down, and the bar and the places stay.
- At 599 pixels wide the places are a row at the bottom; at 600 they are a column on the side.
- Nothing scrolls sideways at 320 pixels wide, with a long word and a long title in it.
- It names what it could not check in a desktop browser: safe areas, the on-screen keyboard.
The skill
App shell: the frame of an app
The frame is the same in almost every app: places to go, a bar with the title, the content. It is written down only in pieces (Material, Apple's guidelines, WCAG, the CSS specifications), so an agent that derives it anew gets one of a dozen known details wrong. Each of them shows only at some width, with some length of content or on a real phone, which is why it passes a quick look.
So don't derive it. Decide three things, copy the base, change what is the project's, and check it running. Write each answer down.
1. Decide before any markup
Page or workspace: what scrolls
Everything else hangs on this.
| Page | Workspace | |
|---|---|---|
| What scrolls | the document | one part of the content; the window stays |
| For | what is read from top to bottom: a list, a dashboard, settings, a form, one thing's page | a conversation, a map, a canvas, an editor, two panes side by side |
| What it gives | the least to get wrong: nothing in it needs a height. On a phone the browser's own bars move away as the page scrolls, and on iOS a tap on the status bar returns to the top | a field or a toolbar that stays at the lower edge; parts that scroll apart |
| Set | data-shell="page" |
data-shell="workspace", and shell-scroll on the part that scrolls |
Default to a page. Take a workspace only when one part of the screen has to stay while another scrolls. Never mix them: a window that scrolls around a box that also scrolls is the most common fault in a generated layout.
One screen is both, by width: two panes side by side that are a single pane on a phone, such as
a list beside the thing chosen from it. Set data-shell="split". From 600px it is a workspace,
so each pane scrolls on its own; below, one pane shows at a time and it is a page. The panes and
the way between them are the skill app-navigation.
The places
List the top-level places in order, each with one or two words and a glyph. The same list is the row at the lower edge on a phone and the column on the side from 600px: same places, same order, same words.
- Three to five fit the row, and fewer are easier to take in. With more, the rest need a home on the phone: a last place that lists them, or a drawer from the project's component library.
- Don't put all the places behind a menu button when they fit. Hidden navigation is found about half as often.
- What the sidebar holds beyond the places (an account, a search) needs a home on the phone too. Decide where before building the sidebar.
The title
One per screen, in the bar, as the h1. It names the place or the thing on screen, never the app.
Don't repeat it as a heading at the top of the content.
2. Copy the base
assets/app-shell.css: the frame, about 450 lines with its comments. Copy it whole.assets/page.htmlandassets/workspace.html: the markup of each kind, working. Open them.
Change: the tokens at the top (map each to a colour or size the project already has; never add a new value), the places and their glyphs, the content. Where the project has a component library, its buttons and links go inside; the shell's classes stay on the frame.
Keep: every line marked TRAP. Each is there because leaving it out breaks something a quick
look doesn't show. If one has to go, say which and why.
In a utility-class project port the declarations one for one; don't rebuild the layout from
the class names you remember. references/traps.md names the usual class for each.
The base is a starting frame, not a look. It uses the system's colours and font so that it shows nothing of its own. The project's design system decides the look.
3. Two size classes
| Compact, below 600px | Regular, from 600px | |
|---|---|---|
| The places | a row at the lower edge, glyph over name | a column on the side, glyph beside name |
| The bar | the title and one or two actions | the title and the page's actions |
| Side margin | 16px | 32px |
Shared by both: the places with their order and words, the title, what every action does.
- The switch is a width, 600px, where Material's compact range ends. A tablet held upright is
regular. The query is in
em, so a larger text size in the browser reaches the compact frame sooner. - Density follows the pointer, not the width. A row or a button is 36px under a mouse and 44px
under a finger (
pointer: coarse). A touch tablet is regular and still gets 44px; a narrow desktop window is compact and doesn't. - A phone may do less on purpose. Decide what the compact frame leaves out; don't squeeze the regular one into a column.
4. The traps
Check each one on the running page. Each is a yes or a finding. references/traps.md has, for
each, what you see when it's wrong, why, the fix and its source.
- One scroller. In every state exactly one thing scrolls up and down under the pointer.
- The sidebar stays while a long page scrolls.
- Nothing under a bar. The last line of content ends above the row of places, and a jump to an anchor or a Tab into the content lands below the top bar.
- Heights in
svhordvh, nevervh. - Nothing scrolls sideways at 320px wide, with a long word, a long title and a wide table in the content.
- The title gives way: it ends in an ellipsis before it pushes an action off the bar.
- Sticky parts stick: no ancestor of a sticky bar has
overflowset. - The frame holds still between a short page and a long one.
- Where you are is marked at a glance, with
aria-current="page", not by a slightly lighter grey. - A finger gets 44px, and nothing keeps its hover look after a tap.
- Tab starts at the skip link, then the places, the bar, the content.
- The edges line up: title, content and the glyph of the last action share one left and one right edge, and the first place sits on the bar's line.
- The frame clears the device: the notch, the home indicator, a rounded corner.
- A field at the lower edge stays above the keyboard (workspace only).
5. Check it running
Never from the code. Open the page.
- Widths: 320, 375, 599, 600, 768, 1024, 1440. At each: a short page and a long one, light and dark.
- Content: the longest title, a long unbroken word, no places selected, the most places.
- Input: keyboard only (Tab through it); a touch device or
pointer: coarseemulation; the browser zoomed to 400%. - What a desktop browser can't show: safe areas, the on-screen keyboard, a phone browser's moving bars. Check them on a device or a simulator, or say that they are unchecked.
6. Report
- Page or workspace, and the reason in one sentence.
- The places, in order, and where anything beyond five went.
- Which
TRAPlines were changed or dropped, and why. Usually none. - The traps that failed and what was fixed.
- What is unchecked, and what only the user can decide.
references/traps.md Show Close
The traps of an app's frame
The fourteen checks of SKILL.md, each with what you see when it's wrong, why it happens, the fix
as assets/app-shell.css has it, the usual utility class, and where the rule comes from. Read the
entry of a check that failed, or all of them before porting the base into a utility-class project.
1. One scroller
- You see: two scrollbars side by side. The wheel moves the page until it ends, then the box inside it, or the other way round. The bar leaves with the page.
- Why: a wrapper with a fixed height (
height: 100vh,h-screen) sits in a document that still grows, or a box gotoverflow: autoto "make it scroll" while its parents have no height to hold it to. - Fix: decide page or workspace and build only that. Page: nothing in the frame has a fixed
height or
overflow, except the sidebar. Workspace: the shell is exactly as tall as the window, and every box from the shell down to the part that scrolls hasmin-height: 0. A grid or flex child is otherwise at least as tall as its content, so it grows and the page scrolls instead. - Utility classes: page
min-h-svhon the shell; workspaceh-dvhon the shell andmin-h-0on every flex or grid child down to the scroller, which getsoverflow-auto. - Source: CSS Flexible Box Layout, "Automatic Minimum Size of Flex Items"; CSS Grid Layout, "Automatic Minimum Size of Grid Items".
- Why a page is the default: it has none of this. And the document is what a phone's browser
watches. In Chromium the address bar moves with the root scroller, which is the document unless
an inner scroller fills the whole window. WebKit on iOS answers a tap on the status bar only for
the document, not for a box that scrolls inside it. (Chromium,
core/page/scrolling/README.md; WebKit,ScrollingTreeScrollingNodeDelegateIOS.mm. Both read from the source code, not from documentation.)
2. The sidebar stays
- You see: on a long page the sidebar scrolls out of view, or it is as long as the page and its lower part can never be reached.
- Why: the sidebar is a column of the page's grid, so it is as tall as the page.
- Fix:
position: sticky; top: 0; align-self: start; height: 100svh; overflow-y: auto. It has the window's height and scrolls on its own when it holds more.overscroll-behavior-y: containkeeps its scroll from moving the page when it reaches its end. - Utility classes:
sticky top-0 self-start h-svh overflow-y-auto overscroll-y-contain. - Why
svhand notdvh: a column that follows the browser's moving bars changes height while the page scrolls.
3. Nothing under a bar
- You see: the last row of a list can't be read because the row of places covers it. Or a link
to
#sectionlands with the heading under the top bar, or Tab moves focus to a field that the bar hides. - Why: a bar with
position: fixedis taken out of the page, so the content runs under it. A sticky top bar covers whatever scrolls to the top edge. - Fix, lower bar: make it
position: sticky; bottom: 0in a grid row of its own. It stays at the window's lower edge and still takes its space. With a fixed bar the content needspadding-bottomof the bar's height plus the safe area, and that pair drifts apart. - Fix, top bar:
scroll-padding-topon the scroller (htmlin a page), the bar's height plus a little air. It applies to anchor jumps and to focus moving by keyboard. - Fix, focus under the lower bar:
scroll-padding-bottomof that bar's height (--shell-cover-bottom). The bar takes its own space, but it still lies over the window's lower edge: a link that takes focus behind it counts as in view, and the browser leaves it there. Measured on 27 November 2026: a link 17px below the bar's upper edge stayed hidden without it. - Utility classes:
sticky bottom-0;scroll-pt-18onhtmlfor a 56px bar. - Source: WCAG 2.2, 2.4.11 Focus Not Obscured (Minimum), level AA, which names sticky headers
as the usual cause and
scroll-paddingas a sufficient technique (C43); MDN,scroll-padding-top.
4. Heights in svh or dvh, never vh
- You see: on a phone the row of places sits under the browser's own bar, or the page is a few pixels taller than the screen and scrolls although it holds almost nothing.
- Why: on a phone
100vhis the height of the window with the browser's bars moved away, the largest it can be. While they show, the window is shorter than that. - Fix: three units say which height is meant.
svh: the bars showing, the smallest window.lvh: the bars away, the largest.dvh: whatever it is right now.- A page's minimum height:
min-height: 100svh. It never jumps. - A workspace's height:
height: 100dvh. The frame is the window, as it is now. - A sticky column:
height: 100svh. - Keep a
vhline before each for browsers from before 2022 (the units came with Safari 15.4, Firefox 101 and Chrome 108).
- A page's minimum height:
- Utility classes:
min-h-svh,h-dvh,h-svh. Neverh-screenormin-h-screenin a frame. - Source: CSS Values and Units Level 4, "Viewport-percentage Lengths"; web.dev, "The large, small, and dynamic viewport units".
5. Nothing scrolls sideways
- You see: the whole page moves sideways on a phone, usually by a few pixels, sometimes by a table's width.
- Why: a grid column of
1frisminmax(auto, 1fr): it never gets narrower than its widest content. A flex child has the same minimum. One table, one line of code, one long address or one picture with a set width widens the column, and the column widens the page. - Fix:
grid-template-columns: minmax(0, 1fr)for the content column,min-width: 0on the content,overflow-wrap: anywhereso a long word breaks. What is wide by nature (a table, code) gets a wrapper of its own withoverflow-x: autoand scrolls inside it. - Don't: hide it with
overflow-x: hiddenon the body. That cuts content off and breaks sticky bars (trap 7). - Utility classes:
grid-cols-[minmax(0,1fr)],min-w-0,[overflow-wrap:anywhere],overflow-x-autoon the table's wrapper. - Source: CSS Grid Layout, "Flexible Lengths: the fr unit"; WCAG 2.2, 1.4.10 Reflow, level AA (no scrolling in two directions at a width of 320 CSS pixels).
6. The title gives way
- You see: a long title pushes the bar's actions off the screen, or wraps and makes the bar two lines tall.
- Why: the title is a flex child and won't shrink below its text.
- Fix: on the title
flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap. The actions getflex: none. - Utility classes:
min-w-0 flex-1 truncateon the title,shrink-0on the actions.
7. Sticky parts stick
- You see: a bar with
position: stickyscrolls away like any other element. - Why: a sticky element sticks inside its nearest ancestor that can scroll, and any ancestor
with
overflow: hidden,autoorscrollcounts as one, even when it never scrolls. The usual culprit is anoverflow-x: hiddenon a wrapper, put there to hide a sideways scroll. - Fix: remove that
overflowand fix the sideways scroll at its cause (trap 5). Where something really has to be clipped,overflow: clipclips without making a scroller, as long as it is set for both directions:clipone way besideautothe other way still makes one. - Source: CSS Positioned Layout Level 3, sticky positioning; MDN,
position; CSS Overflow Level 3,overflow: clip.
8. The frame holds still
- You see: going from a short page to a long one, everything jumps a few pixels to the left.
- Why: on systems that draw scrollbars in the layout, the scrollbar takes width only when the content overflows.
- Fix:
scrollbar-gutter: stableon what scrolls:htmlin a page, the scrolling part in a workspace. Browsers without it (Safari before 18.2) ignore the line and shift as before. - Utility classes:
[scrollbar-gutter:stable]. - Source: CSS Overflow Level 3,
scrollbar-gutter; MDN,scrollbar-gutter.
9. Where you are is marked
- You see: the current place is the same as the others but a slightly darker grey. Nobody can tell at a glance where they are.
- Fix: the link of the current place carries
aria-current="page", and the style hangs on that attribute, so what a screen reader hears and what the eye sees can't drift apart. Mark it with more than a tone: a heavier weight and a ground of its own (a pill behind the glyph in the row, the whole row in the column). - Utility classes:
aria-[current=page]:font-semibold aria-[current=page]:bg-…. - Source: WAI-ARIA 1.2,
aria-current; Nielsen's first heuristic, visibility of system status; Material 3, navigation bar (the active indicator).
10. A finger gets 44px
- You see: on a touch tablet the sidebar's rows are as tight as on a desktop and get mistapped. After a tap, a row keeps its hover colour until something else is tapped.
- Why: the size was tied to the window's width, and a tablet is wide.
:hovermatches the last thing touched. - Fix: tie size to the pointer:
@media (pointer: coarse)raises rows and buttons from 36px to 44px. Put hover styles in@media (hover: hover). - Utility classes:
pointer-coarse:h-11. Tailwind 4 already limitshover:to devices that hover; a hand-written[&:hover]selector skips that and needs the media query itself. - Source: Apple Human Interface Guidelines, Buttons (a hit region of at least 44 by 44
points); Material 3, target sizes (48 by 48 dp for touch); WCAG 2.2, 2.5.8 Target Size (Minimum),
level AA, 24 by 24 CSS pixels as the floor, and 2.5.5 (Enhanced), level AAA, 44 by 44; MDN,
pointerandhovermedia features.
11. Tab starts at the skip link
- You see: a keyboard user has to pass every place on every page before reaching the content. Or focus runs through the content before the places that are drawn before it.
- Fix: the order in the markup is skip link, places, bar, content. The skip link points at the
content, which has an
idandtabindex="-1"so it can take focus. After a navigation inside the app, focus moves to the content or its title; most routers do it, check that this one does. - Source: WCAG 2.2, 2.4.1 Bypass Blocks (level A) and 2.4.3 Focus Order (level A).
12. The edges line up
- You see: the title starts a few pixels left or right of the text under it. The plus at the bar's end sits further in than the content's right edge. The first place in the sidebar is higher or lower than the title beside it.
- Why: the bar and the content got their side padding separately, and a button's glyph sits inside a hit area that is larger than the glyph.
- Fix: one token for the side margin, used by the bar and by the content. The last action is pulled out by half the difference between its hit area and its glyph. The sidebar's top padding is half the difference between the bar's height and a row's height, so the first row is centred on the bar's line.
13. The frame clears the device
- You see: on a phone held sideways the content keeps white bands left and right, or the row of places runs under the home indicator, or the title sits under the notch.
- Why: by default (
viewport-fit=auto) the browser keeps the whole page inside the safe area, which leaves the bands. Withviewport-fit=coverthe page fills the screen and has to keep its own content clear of the edges. - Fix:
viewport-fit=coverin the viewport meta. Thenenv(safe-area-inset-top)on the top bar's padding,env(safe-area-inset-bottom)on the row of places, left and right on the shell. Each bar adds the inset to its own padding, so its ground reaches the edge and its content doesn't. - Utility classes:
pt-[env(safe-area-inset-top)],pb-[env(safe-area-inset-bottom)]. - Source: WebKit, "Designing Websites for iPhone X"; CSS Environment Variables Level 1, safe area inset variables; Chrome for Developers, "Edge-to-edge" (Chrome on Android from 135).
- Can't be checked in a desktop browser. On a rectangular display the insets are zero.
14. A field at the lower edge stays above the keyboard
- You see: in a conversation the on-screen keyboard covers the field you are typing in.
- Why: by default the keyboard changes only what is visible, not the page's layout. A frame
of
100dvhthen still reaches down behind the keyboard. - Fix:
interactive-widget=resizes-contentin the viewport meta. The keyboard then makes the window itself shorter, the100dvhframe follows, and the field stays on top of the keyboard. Chrome on Android (from 108) and Firefox on Android (from 133) support it. No released Safari did in November 2026: on iOS the field needs thevisualViewportAPI to follow the keyboard. That is script, and not part of this base. - Also: a text field is at least 16px. iOS zooms the page when a smaller field takes focus.
- Source: MDN, viewport meta tag,
interactive-widget; CSS Viewport Module, "Interactive widget"; Chrome for Developers, "Prepare for viewport resize behavior changes coming to Chrome on Android". - Can't be checked in a desktop browser.
The standards behind the frame
- Size classes. Material 3's breakpoints by width (Android calls them window size classes): compact below 600dp, medium from 600, expanded from 840, large from 1200, extra-large from 1600. This base uses the first line only: compact below 600, regular from there. Apple's size classes, compact and regular, name the same split.
- The row of places. Material 3, navigation bar: three to five destinations. Apple's Human Interface Guidelines, tab bars: for moving between an app's top-level sections, visible in each of them, never for actions; as few tabs as the app needs, because tabs that don't fit end up behind a More tab.
- The column of places. Material 3 recommends a navigation rail from the medium width up, and since May 2025 the expanded rail in place of the navigation drawer. Apple's guidelines say a sidebar needs a lot of room, and on iPad prefer a tab bar that can open into a sidebar. This base follows Material and the habit of web apps: a column from 600px.
- Visible places beat a menu. Nielsen Norman Group, Kara Pernice and Raluca Budiu, "Hamburger Menus and Hidden Navigation Hurt UX Metrics" (2016): hiding a site's main navigation roughly halves how often people find it, and tasks take longer.
- The term. "App shell" comes from Google's application shell architecture for web apps that load at once: the minimal HTML, CSS and JavaScript of the interface, cached, with the content loaded into it (Addy Osmani and Matt Gaunt, "Instant Loading Web Apps with an Application Shell Architecture", 2015). This skill uses the word for the frame's layout only, not for caching.
- Newer CSS. The base uses what every current browser has, plus one enhancement behind
@supports: the line under the bar that appears on scroll (scroll-driven animations: Chrome 115, Safari 26, Firefox 159). - Chrome's Modern Web Guidance (github.com/GoogleChrome/modern-web-guidance) has no guide for
the frame itself, which is why this skill exists. Its guides cover the pieces, and go further
on each:
css/css-layout(min-width: 0,overflow: clip,scrollbar-gutter),user-experience/form-factor-adaptation(target sizes, safe areas, reflow at 320px),ui-atoms/state-aware-sticky-headers,ui-components/navigation-drawerandui-components/stack-drill-down. Read them in the repository; its command-line tool reports usage to Google.
assets/app-shell.css Show Close
/*
* app-shell.css: the frame of an app. Places to go, a bar with the title, the content.
*
* Copy this file. Map the tokens to the project's own. Keep every line marked TRAP: each one
* prevents a fault that shows only at some width, some length of content or on some device.
*
* <a class="shell-skip" href="#content">Skip to content</a>
* <div class="shell" data-shell="page"> page: the document scrolls
* <nav class="shell-nav" aria-label="Main"> workspace: the window is fixed, a part scrolls
* split: a workspace from 600px, a page below
* <ul class="shell-places"> <li><a href aria-current="page"><svg/><span>Name</span></a>
* <header class="shell-bar"> <h1 class="shell-title"> <button class="shell-action">
* <main class="shell-content" id="content" tabindex="-1">
*
* Two size classes, by the window's width: compact below 600px (the places are a row at the
* bottom), regular from 600px (the places are a column on the side). Working examples: page.html,
* workspace.html. The page needs
* <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
*/
:root {
color-scheme: light dark;
/* Tokens. These follow the system's light and dark; replace them with the project's. */
--shell-surface: Canvas;
--shell-recess: color-mix(in srgb, CanvasText 5%, Canvas); /* the sidebar's ground */
--shell-text: CanvasText;
--shell-muted: color-mix(in srgb, CanvasText 62%, Canvas);
--shell-line: color-mix(in srgb, CanvasText 14%, Canvas);
--shell-current: color-mix(in srgb, CanvasText 10%, Canvas); /* behind the place you are in */
--shell-focus: Highlight;
--shell-gutter: 1rem; /* the content's side margin; the bar's too, so the title sits on the content's edge */
--shell-nav-width: clamp(12rem, 24vw, 16rem);
--shell-bar-height: 3.5rem;
--shell-tabs-height: 3.5rem;
--shell-hit: 2.25rem; /* a row or a button under a mouse: 36px */
--shell-layer: 10; /* the bars, above the content; overlays go above this */
/* How far the frame's bars reach over whatever scrolls. Something sticky inside the content (a
table's header, a bar of actions) stops there instead of sliding under them:
`top: var(--shell-cover-top)`, `bottom: var(--shell-cover-bottom)`. */
--shell-cover-top: calc(var(--shell-bar-height) + env(safe-area-inset-top, 0px));
--shell-cover-bottom: calc(var(--shell-tabs-height) + env(safe-area-inset-bottom, 0px));
}
/* TRAP: density follows the pointer, not the width. A touch tablet is wide and still needs 44px;
a narrow desktop window does not. */
@media (pointer: coarse) {
:root {
--shell-hit: 2.75rem;
}
}
html {
/* TRAP: a jump to #anchor, or focus moving by Tab, lands under the sticky bar without this. */
scroll-padding-top: calc(var(--shell-bar-height) + env(safe-area-inset-top, 0px) + 1rem);
/* TRAP: and under the row of places at the bottom. To the browser a link behind that row is
in view, so it doesn't scroll it out from under it. */
scroll-padding-bottom: var(--shell-cover-bottom);
/* TRAP: without a reserved gutter the frame shifts sideways between a short page and a long one. */
scrollbar-gutter: stable;
}
body {
margin: 0;
}
.shell,
.shell *,
.shell-skip {
box-sizing: border-box;
}
.shell {
display: grid;
/* TRAP: `1fr` means minmax(auto, 1fr): one wide child (a table, a long word) widens the whole
page. minmax(0, 1fr) lets the column stay as wide as the window. */
grid-template-columns: minmax(0, 1fr);
grid-template-rows: auto minmax(0, 1fr) auto; /* bar, content, places */
/* TRAP: 100vh is taller than a phone's screen while the browser's bars show, so the last row
ends up under them. svh is the screen with the bars showing. */
min-height: 100vh;
min-height: 100svh;
padding-left: env(safe-area-inset-left, 0px);
padding-right: env(safe-area-inset-right, 0px);
background: var(--shell-surface);
color: var(--shell-text);
font: 1rem/1.5 system-ui, sans-serif;
-webkit-tap-highlight-color: transparent;
}
.shell :focus-visible,
.shell-skip:focus-visible {
outline: 2px solid var(--shell-focus);
outline-offset: 2px;
}
/* The first stop of the Tab key: over the places, into the content. Hidden until it has focus. */
.shell-skip {
position: absolute;
top: 0.5rem;
inset-inline-start: 0.5rem;
z-index: calc(var(--shell-layer) + 1);
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
background: var(--shell-surface);
color: var(--shell-text);
transform: translateY(-200%);
}
.shell-skip:focus {
transform: none;
}
/* ---- The bar: the title once, the page's own actions at its end ---- */
.shell-bar {
grid-row: 1;
position: sticky;
top: 0;
z-index: var(--shell-layer);
display: flex;
align-items: center;
gap: 0.5rem;
min-height: calc(var(--shell-bar-height) + env(safe-area-inset-top, 0px));
padding: env(safe-area-inset-top, 0px) var(--shell-gutter) 0;
border-bottom: 1px solid var(--shell-line);
background: var(--shell-surface);
}
.shell-title {
flex: 1;
/* TRAP: a flex child never shrinks below its text. Without this a long title pushes the actions
off the screen instead of ending in an ellipsis. */
min-width: 0;
margin: 0;
overflow: hidden;
font-size: 1.0625rem;
font-weight: 600;
line-height: 1.3;
text-overflow: ellipsis;
white-space: nowrap;
}
.shell-action {
display: grid;
flex: none;
place-items: center;
min-width: var(--shell-hit);
min-height: var(--shell-hit);
padding: 0;
border: 0;
border-radius: 0.5rem;
background: none;
color: inherit;
font: inherit;
cursor: pointer;
}
/* The glyph, not its hit area, sits on the content's edge. */
.shell-action:last-child {
margin-inline-end: calc((var(--shell-hit) - 1.25rem) / -2);
}
.shell-action svg {
width: 1.25rem;
height: 1.25rem;
}
/* ---- The content ---- */
.shell-content {
grid-row: 2;
/* TRAP: the same as the title's. A grid child never shrinks below its content either. */
min-width: 0;
overflow-wrap: anywhere; /* a long word or address wraps instead of widening the page */
}
/* It takes focus when the skip link or a navigation sends it there; that needs no ring. */
.shell-content:focus {
outline: none;
}
/* A reading column inside the content: text and forms. Tables and canvases go without it. */
.shell-page {
max-width: 48rem;
padding: 1rem var(--shell-gutter) 3rem;
}
/* ---- The places: compact, a row at the bottom ---- */
.shell-nav {
grid-row: 3;
/* Sticky, in a row of its own: it stays at the screen's lower edge and still takes its space,
so the content's last line is never under it. (A fixed bar needs padding to make up for it.) */
position: sticky;
bottom: 0;
z-index: var(--shell-layer);
padding-bottom: env(safe-area-inset-bottom, 0px); /* clear of the home indicator */
border-top: 1px solid var(--shell-line);
background: var(--shell-surface);
}
.shell-places {
display: flex;
margin: 0;
padding: 0;
list-style: none;
}
.shell-places li {
flex: 1;
min-width: 0;
}
.shell-places a {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.125rem;
min-height: var(--shell-tabs-height);
padding-inline: 0.25rem;
color: var(--shell-muted);
font-size: 0.6875rem;
line-height: 1.2;
text-decoration: none;
outline-offset: -2px;
}
.shell-places span {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* The glyph in a pill: where you are shows at a glance, not as a slightly darker grey.
aria-current is "page" on the place's own page and "true" on a page inside it. */
.shell-places svg {
box-sizing: content-box;
width: 1.5rem;
height: 1.5rem;
padding: 0.125rem 1rem;
border-radius: 999px;
}
.shell-places a:is([aria-current='page'], [aria-current='true']) {
color: var(--shell-text);
font-weight: 600;
}
.shell-places a:is([aria-current='page'], [aria-current='true']) svg {
background: var(--shell-current);
}
/* TRAP: on a touch screen :hover sticks to the last thing tapped. Only a pointer that can hover gets it. */
@media (hover: hover) {
.shell-places a:hover {
color: var(--shell-text);
}
.shell-action:hover {
background: var(--shell-current);
}
}
/* ---- Regular: from 600px the places are a column on the side ---- */
/* In em, so a larger text size in the browser moves to the compact frame sooner. */
@media (min-width: 37.5em) {
:root {
--shell-gutter: 2rem;
--shell-cover-bottom: 0px; /* the places are beside the content now, not under it */
}
.shell {
grid-template-columns: var(--shell-nav-width) minmax(0, 1fr);
grid-template-rows: auto minmax(0, 1fr);
}
.shell-bar {
grid-area: 1 / 2;
}
.shell-content {
grid-area: 2 / 2;
}
.shell-nav {
grid-area: 1 / 1 / -1 / 2;
/* TRAP: without a height of its own and `sticky`, the sidebar scrolls away with a long page.
svh, not dvh: a column that follows the browser's bars resizes while you scroll. */
top: 0;
bottom: auto;
align-self: start;
height: 100vh;
height: 100svh;
overflow-y: auto;
overscroll-behavior-y: contain; /* its own scroll ends there and doesn't move the page */
/* the first row sits on the bar's line */
padding: calc((var(--shell-bar-height) - var(--shell-hit)) / 2) 0.5rem 0.5rem;
border-top: 0;
background: var(--shell-recess);
}
.shell-places {
flex-direction: column;
gap: 0.125rem;
}
.shell-places a {
flex-direction: row;
justify-content: flex-start;
gap: 0.75rem;
min-height: var(--shell-hit);
padding-inline: 0.75rem;
border-radius: 0.5rem;
font-size: 0.9375rem;
}
.shell-places svg {
flex: none;
width: 1.25rem;
height: 1.25rem;
padding: 0;
border-radius: 0;
}
.shell-places a:is([aria-current='page'], [aria-current='true']),
.shell-places a:is([aria-current='page'], [aria-current='true']) svg {
background: none;
}
.shell-places a:is([aria-current='page'], [aria-current='true']) {
background: var(--shell-current);
}
@media (hover: hover) {
.shell-places a:hover {
background: var(--shell-current);
}
}
}
/* ---- Workspace: the window is fixed and a part of the content scrolls ---- */
/* Nothing of the document scrolls, so it needs no gutter and should not bounce at its edges.
(Safari ignores overscroll-behavior on a scroller that has nothing to scroll.) */
html:has(.shell[data-shell='workspace']) {
overflow: hidden;
scrollbar-gutter: auto;
overscroll-behavior: none;
}
.shell[data-shell='workspace'] {
/* dvh here: the frame is the window, and follows it when the browser's bars or, where the
browser resizes the page for it, the keyboard change its height. */
height: 100vh;
height: 100dvh;
min-height: 0;
}
.shell[data-shell='workspace'] .shell-content {
display: flex;
flex-direction: column;
/* TRAP: without min-height: 0 the content grows as tall as what is in it, and the page scrolls
instead of the part that should. */
min-height: 0;
}
/* The part that scrolls. Everything beside it in the content (a composer, a toolbar) stays.
Only inside a fixed window: in a page it must not be a scroller, or sticky parts inside it
stop sticking. */
.shell[data-shell='workspace'] .shell-scroll {
flex: 1;
min-height: 0; /* TRAP: as above, for a flex child */
overflow: auto;
overscroll-behavior: contain;
scrollbar-gutter: stable;
/* the bars are outside this scroller, so nothing covers its edges */
--shell-cover-top: 0px;
--shell-cover-bottom: 0px;
}
.shell[data-shell='workspace'] .shell-nav {
position: static;
}
@media (min-width: 37.5em) {
.shell[data-shell='workspace'] .shell-nav {
align-self: stretch;
height: auto;
min-height: 0;
}
}
/* ---- Split: two panes side by side that are one pane on a phone ---- */
/* The kind of scrolling follows the number of panes. From 600px the frame is a workspace, the
same rules as above, so each pane can scroll on its own. Below, one pane shows at a time and
the frame is a page. The panes themselves are app-navigation's. */
@media (min-width: 37.5em) {
html:has(.shell[data-shell='split']) {
overflow: hidden;
scrollbar-gutter: auto;
overscroll-behavior: none;
}
.shell[data-shell='split'] {
height: 100vh;
height: 100dvh;
min-height: 0;
}
.shell[data-shell='split'] .shell-content {
display: flex;
flex-direction: column;
min-height: 0;
}
.shell[data-shell='split'] .shell-scroll {
flex: 1;
min-height: 0;
overflow: auto;
overscroll-behavior: contain;
scrollbar-gutter: stable;
--shell-cover-top: 0px;
--shell-cover-bottom: 0px;
}
.shell[data-shell='split'] .shell-nav {
position: static;
align-self: stretch;
height: auto;
min-height: 0;
}
}
/* ---- A line under the bar only once something has scrolled under it ---- */
/* Where the browser can tie an animation to the scroll position. Elsewhere the line is always there. */
@supports (animation-timeline: scroll()) {
.shell[data-shell='page'] .shell-bar {
animation: shell-bar-line linear both;
animation-timeline: scroll(root);
animation-range: 0 0.5rem;
}
@keyframes shell-bar-line {
from {
border-bottom-color: transparent;
}
}
}
assets/page.html Show Close
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Page</title>
<link rel="stylesheet" href="app-shell.css" />
<style>
/* This example's own content. Not part of the shell. */
.rows {
margin: 1.5rem 0 0;
padding: 0;
list-style: none;
}
.rows li {
padding-block: 0.625rem;
border-top: 1px solid var(--shell-line);
}
.lead {
margin: 0 0 0.75rem;
color: var(--shell-muted);
}
</style>
</head>
<body>
<a class="shell-skip" href="#content">Skip to content</a>
<div class="shell" data-shell="page">
<nav class="shell-nav" aria-label="Main">
<ul class="shell-places">
<li>
<a href="page.html" aria-current="page">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" aria-hidden="true"><circle cx="12" cy="12" r="7" /></svg>
<span>Today</span>
</a>
</li>
<li>
<a href="workspace.html">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linejoin="round" aria-hidden="true"><path d="M12 5l7.5 13h-15z" /></svg>
<span>Inbox</span>
</a>
</li>
</ul>
</nav>
<header class="shell-bar">
<h1 class="shell-title">Today</h1>
<button type="button" class="shell-action" aria-label="Add">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14" /></svg>
</button>
</header>
<main class="shell-content" id="content" tabindex="-1">
<div class="shell-page">
<p class="lead">Scroll this page.</p>
<p>
The whole document scrolls. The bar stays at the top, and the places stay in reach: a row at
the bottom below 600 pixels, a column on the side from there.
</p>
<p>The last row is never under the bar at the bottom: that bar takes its own space.</p>
<ol class="rows">
<li>Row 1</li>
<li>Row 2</li>
<li>Row 3</li>
<li>Row 4</li>
<li>Row 5</li>
<li>Row 6</li>
<li>Row 7</li>
<li>Row 8</li>
<li>Row 9</li>
<li>Row 10</li>
<li>Row 11</li>
<li>Row 12</li>
<li>Row 13</li>
<li>Row 14</li>
<li>Row 15</li>
<li>Row 16</li>
<li>Row 17</li>
<li>Row 18</li>
<li>Row 19</li>
<li>Row 20</li>
<li>Row 21</li>
<li>Row 22</li>
<li>Row 23</li>
<li id="last">Row 24, the last</li>
</ol>
</div>
</main>
</div>
</body>
</html>
assets/workspace.html Show Close
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- interactive-widget=resizes-content: where the browser supports it, the on-screen keyboard
makes the window shorter instead of covering the field at the bottom -->
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" />
<title>Workspace</title>
<link rel="stylesheet" href="app-shell.css" />
<style>
/* This example's own content. Not part of the shell. */
.messages {
display: flex;
flex-direction: column;
gap: 0.75rem;
margin: 0;
padding: 1rem var(--shell-gutter);
list-style: none;
}
.messages li {
max-width: 34rem;
padding: 0.625rem 0.875rem;
border-radius: 1rem;
background: var(--shell-recess);
}
.composer {
display: flex;
gap: 0.5rem;
padding: 0.75rem var(--shell-gutter);
border-top: 1px solid var(--shell-line);
}
.composer input {
flex: 1;
min-width: 0;
min-height: 2.75rem;
padding-inline: 0.875rem;
border: 1px solid var(--shell-line);
border-radius: 999px;
background: var(--shell-surface);
color: inherit;
/* 16px: iOS zooms the page when a smaller field takes focus */
font: inherit;
}
</style>
</head>
<body>
<a class="shell-skip" href="#content">Skip to content</a>
<div class="shell" data-shell="workspace">
<nav class="shell-nav" aria-label="Main">
<ul class="shell-places">
<li>
<a href="page.html">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" aria-hidden="true"><circle cx="12" cy="12" r="7" /></svg>
<span>Today</span>
</a>
</li>
<li>
<a href="workspace.html" aria-current="page">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linejoin="round" aria-hidden="true"><path d="M12 5l7.5 13h-15z" /></svg>
<span>Inbox</span>
</a>
</li>
</ul>
</nav>
<header class="shell-bar">
<h1 class="shell-title">Inbox</h1>
</header>
<main class="shell-content" id="content" tabindex="-1">
<ol class="shell-scroll messages">
<li>The window doesn't scroll here. Only this list does.</li>
<li>The field below stays where it is, at the lower edge.</li>
<li>Use this for a conversation, a map, an editor, or two panes side by side.</li>
<li>Message 4</li>
<li>Message 5</li>
<li>Message 6</li>
<li>Message 7</li>
<li>Message 8</li>
<li>Message 9</li>
<li>Message 10</li>
<li>Message 11</li>
<li>Message 12</li>
<li>Message 13</li>
<li id="last">Message 14, the last</li>
</ol>
<form class="composer" action="#content">
<input type="text" aria-label="Message" placeholder="Write a message" />
</form>
</main>
</div>
</body>
</html>