Layout
Content has a maximum width, cards and tiles sit in a kern-grid, and breakpoints are measured on the container, not on the window.
Tokens
Widths for the page and the sidebar, and three breakpoints. Custom properties do not work in @media or @container conditions, so the breakpoint values are written literally there; the tokens are for documentation and for JavaScript (getComputedStyle(document.documentElement).getPropertyValue('--breakpoint-md')).
| Token | Value | |
|---|---|---|
--content-max | 1280px | |
--content-wide | 1600px | |
--sidebar-width | 240px | |
--breakpoint-sm | 640px | |
--breakpoint-md | 960px | |
--breakpoint-lg | 1280px |
Breakpoints
Kern components switch by the room they really have: kern-grid is a size container, and its columns and the spans of kern-grid-item change at 640, 960 and 1280 px of grid width. A grid in a sidebar, a drawer or half a page therefore behaves like on a small screen, without any extra configuration. Use the same values for your own container queries.
Grid
kern-grid has two modes:
- Auto (default): as many columns of at least
minas fit, e.g. for key figures or device cards. No breakpoints needed. - Columns:
columns="12"withkern-grid-item span="12" span-md="8"for layouts like list and details side by side.
Gaps come from the spacing scale (gap="sm|md|lg"); inside a card, use kern-grid too, not nested cards.
App shell
kern-app-shell is the frame around the pages: a topbar that stays at the top, the content with --content-max and page padding, and an optional footer. With a sidebar slot it adds a side navigation that stands on the left from 960 px and becomes a drawer below, opened by the menu button of kern-topbar. A skip link and the landmarks header, nav and main come with it.
Unlike the grid, the shell decides by its own width with a breakpoint property (default 960), because the side navigation is about the whole window, not one container.
Navigation
Build the side navigation from kern-list variant="nav": one list per group with a heading, links as kern-list-item href with an icon in start and a counter as kern-badge mono in meta. current marks the open page (aria-current="page").
- Routing: the links are real
hrefs, so the navigation works without JavaScript. In a single-page app, listen forkernNavigate(it bubbles) and callpreventDefault()to route yourself;detail.hrefis the target. - New tabs stay with the browser:
kernNavigateonly fires for a plain left click. Ctrl/Cmd, Shift or middle click and links withtargetopen as the browser does. - Drawer: below the breakpoint the navigation is a drawer; a link click closes it and moves focus to the main content, also when your router took over.
- Current page: after routing, move
currentto the new item. - Focus: after a navigation without page load, call
focusMain()on the shell, so keyboard and screen reader users continue in the new content instead of in the navigation. While the drawer is open it waits until the drawer has closed.