Good
<main>
<section aria-labelledby="dashboard-heading">
<lk-stack gap="lg">
<h1 id="dashboard-heading">Dashboard</h1>
<article><h2>Open orders</h2></article>
</lk-stack>
</section>
</main>
Reference · 2.2.0
A pure-CSS layout vocabulary, 85,031 bytes. lk-* tags make layout intent visible. Native HTML carries the meaning. 2.2.0 keeps the 2.0 defaults, and centered overflow lines up at the start where safe exists. Types ship in jsx.d.ts.
Coming from 1.5? MIGRATION.md lists every default that changed, including the restore snippet. The path in the repo is packages/layoutkit/MIGRATION.md.
Load LayoutKit in the document head, or import it from the root of a framework. If the file does not load, the tags render as plain unknown elements and no script fills in. The public registry’s latest is 1.3.2, from 5 July 2026. This site is the 2.2.0 file. A package CDN would still serve 1.3.2.
npm install layoutkit-css@2.2.0
import "layoutkit-css/layoutkit.css";
<link rel="stylesheet" href="/layoutkit.css">
Stack, row, center, spread, grid, box, card, cluster, switcher, sidebar, cover, frame, bleed, spacer, divider, aspect ratio, scroll area, progress, popover, disclosure, menu, dock, select, and columns. Switcher, sidebar, and grid query their own size. Subgrid, row snap, sticky regions, anchors, the 2.1 tags, and the 2.2 attributes stay opt-in. A reversed row sets reading order on its own where reading-flow exists.
No button kit, form theme, icon set, or JavaScript behavior. lk-select styles a native select only where appearance: base-select exists. --lk-base does not paint until you use it. lk-card, lk-text, and lk-weight stay small helpers.
LayoutKit is semantic to the person reading the markup, not to the accessibility tree. Do not replace main, nav, section, article, headings, buttons, links, lists, tables, or form controls.
Good
<main>
<section aria-labelledby="dashboard-heading">
<lk-stack gap="lg">
<h1 id="dashboard-heading">Dashboard</h1>
<article><h2>Open orders</h2></article>
</lk-stack>
</section>
</main>
Bad
<lk-box>
<lk-stack>
<lk-box lk-text="2xl">Dashboard</lk-box>
</lk-stack>
</lk-box>
lk-text is an attribute, not a tag.
| Tag | Purpose | Common attributes |
|---|---|---|
lk-stack | Vertical flow. One child centers unless adapt="off". Children keep min-inline-size: auto. | gap, padding, align, justify, place, fill, full-height, wrap, width, adapt, sticky, stuck, reading, bands |
lk-row | Horizontal flow. One child centers. adapt="scroll" is a snap row that becomes a column below 32rem. reverse flips the picture. Tab order follows it where reading-flow exists. | gap, padding, align, justify, place, fill, wrap, reverse, width, adapt, sticky, stuck, snap, slide, mark, reading, bands |
lk-center | Centers its content. Overflow uses safe center where that keyword exists. Covers a positioned parent unless overlay="off". | fill, full-height, inline, horizontal, vertical, place, width, overlay, square |
lk-box | Block wrapper. pattern and blend are opt-in. | padding, fill, width, flow, sticky, stuck, square, reveal, pattern, blend |
lk-card | Neutral padded block. | padding, radius, surface, border, width, flow, adapt, reveal |
lk-spread | Space-between row. Accepts width. | align, padding, place, width |
lk-grid | Grid. Fixed cols stack from the grid’s own width, default 32rem. Dense flow follows the picture for tab order where reading-flow exists. | cols, rows, responsive, min, gap, col-gap, row-gap, flow, place, place-items, container, subgrid, reading |
lk-cluster | Wrapping group. | gap, place |
lk-switcher | Container row that stacks below 30rem. Default limit is 4. | gap, container, limit, at |
lk-sidebar | Side and content that wrap on the container. | gap, side, container, sticky, stuck, layout |
lk-cover | Minimum-height column. Put center on the middle child. | gap, size |
lk-spacer | Flexible or fixed space. | size |
lk-divider | Visual rule. Default color follows currentColor. | orientation, thickness |
lk-aspect-ratio | Aspect frame. Replaced children fill it. | ratio |
lk-scroll-area | Bounded scroller. Horizontal direction snaps unless snap="off". | direction, max-h, gap, snap, slide, mark, cue |
lk-progress | Scroll progress. Static when timelines are missing. A bare element tracks the viewport. | scope |
lk-popover | Top-layer panel. Does not set display. popover="hint" is the light tooltip. | anchor, match, popover |
lk-disclosure | Layout for native details and summary. The same name opens one at a time. | panel, anchor, side, animate, look |
lk-menu | Invoker plus lk-popover. The invoker is the first child. | anchor, side, match |
lk-columns | Multi-column text. Children avoid splitting. | cols, gap |
lk-frame | Full-width grid. The center track is the measure. Side tracks are the gutter. | width, padding |
lk-bleed | Spans a frame. Subgrid returns its children to the column where subgrid exists. | padding |
lk-dock | Hover grows an item and its neighbors. :has() reaches the previous item. | gap |
lk-select | Native select. Custom picker only where appearance: base-select exists. | width |
Attributes name stable layout behavior. They are not a mirror of every CSS property.
gap, padding, col-gap, and row-gap take none, px, xs through 3xl, and the numeric scale. Named steps are fluid unless you set --space-*.
align, justify, place, place-items, and center. A center value uses safe center where that keyword exists, so overflow lines up at the start. place and justify still win over single-child centering.
fill, full-height, width, size, min, and max-h. A boolean full-height and a plain cover use 100dvh, then 100svh, then 100vh. full-height="container" uses the query container. A toolbar gap is --lk-cover-min: calc(100dvh - var(--lk-toolbar, 0px)) on the host. There is no second height attribute.
responsive and min are auto-fit, so empty tracks collapse. min overrides responsive. Both clamp a track to the container. flow on a grid is row, col, or dense. On a box or card it is the spacing scale.
Omitted at, or at="md", stacks below 30rem. xs 20rem, sm 24rem, lg 40rem, xl 48rem, 2xl 64rem. at="flex" restores the --lk-switch-at formula. limit is 2–6 or off.
Container queries, single-child centering, center overlay, a switcher limit of 4, fluid space, and horizontal snap. Turn one off with container="off", adapt="off", overlay="off", limit="off", or snap="off". Subgrid, sticky, anchor, and reveal stay opt-in.
These regions are the stylesheet. Resize the window. A browser without a feature keeps the previous layout, because each one is wrapped in @supports.
You do not set container to turn this on. container="sm", md, lg, and xl still choose 24rem, 32rem, 48rem, and 64rem for a fixed grid. The narrow frame is 16rem, so the columns stack. The wide frame uses this column.
flex-direction stays row, so place does not reverse reading order. More than four children each take a full row. limit="2" does that at three children.
The side uses --lk-sidebar-width (18rem). The other child wants at least half the container, then they wrap. side="end" flips which child is the side.
Content sits beside the side while the container is wide enough, then moves below it.
slide is full, half, third, or peek. Horizontal scroll areas snap without an extra attribute. snap is what selects the slide size, and what opts a row in.
First slide
Second slide
Third slide
A row or stack with one element child is centered. adapt="figure" bleeds a direct figure to the card edges and keeps the rest inset.
The text stays inset while the figure runs to the edges.
Keep cols so a browser without subgrid still has a template. Gap is inherited unless you set one.
sticky pins the side to --lk-sticky-top. lk-progress scope="nearest" tracks that scroller where scroll timelines exist, and stays a static bar otherwise. Reduced motion keeps the static bar.
Scroll this region. The bar tracks it where scroll timelines exist.
Second paragraph, long enough to overflow the max height.
Third paragraph keeps the scroller honest.
Fourth paragraph is the end of the notes.
The side panel sticks while this column is on screen.
The menu invoker is a real button. anchor tethers the panel with position-area where that exists. Disclosure uses native details. Height animation requires interpolate-size and is skipped when motion is reduced.
lk-columns flows text across 2, 3, or 4 columns. Direct children do not split. The center below covers its positioned parent.
First point stays in one column.
Second point follows the flow.
Third point fills the last column.
These are off until you use the tag or the attribute. pattern, blend, and bands are in the stylesheet and do nothing until set. --lk-base derives --lk-complement, --lk-tetrad, and --lk-tetrad-2 where relative oklch() parses. --lk-hue is a registered angle so a transition can interpolate it. This page does not animate it.
The center track is min(100% - gutters, measure). Side tracks are at least a fluid gutter. lk-bleed spans the frame. Where subgrid exists, its children sit back in the column. width="sm" here is 30rem.
The measure stays put. Gutters take the rest.
This band is the width of the frame.
look="panel" is the border. The shared name is HTML, so one details group stays open. The dock grows a hovered item and its neighbors. The select is native. Custom picker styling applies only where appearance: base-select exists.
Orders leave on weekday mornings.
Opening this closes Shipping.
These replace a listener or a DOM shuffle. Each one is inside @supports. A phone can use the click, scroll, and wrap paths without the newest engine.
The reversed row shows Three, then Two, then One. Where reading-flow exists, tab order follows that picture. spot="first" moves Save to the start only in those browsers. Firefox and Safari leave Save last, which is still the source order, and both buttons still work.
Scroll this region. The page sets --lk-sticky-top so the real header clears the masthead, and this demo sets it back to 0. Where scroll-state queries exist, the title gets a hairline once it sticks. The query cannot paint the sticky element, so the line is on its child. Other browsers keep a plain sticky title.
Section title
First note sits under the title.
Second note gives the region something to scroll.
Third note keeps the scroller honest.
Fourth note is the end of the section.
Fifth note is here so the region actually scrolls.
Sixth note clears the title.
mark="current" outlines the snapped slide’s contents where scroll-state queries exist. The hint opens on click through popovertarget, including on a phone. interestfor adds hover and focus where interest invokers exist. match="width" makes the panel at least as wide as the button where anchor-size() exists.
First highlight
Second highlight
Third highlight
cue fades the end of a vertical scroller while more content sits below, where scroll-state queries exist. At the end the fade goes away. A horizontal scroller is unchanged.
First note.
Second note.
Third note.
Fourth note is the end.
Each primitive, with the attribute that changes it. A root lk-progress would pin itself to the viewport, so use scope="nearest" inside a region.
One
Two
Padded box
Top
Middle
Bottom
Above
First note.
Second note.
Third note.
Fourth note.
Content
lk-card, lk-text, and lk-weight stay small on purpose. 2.1.0 adds opt-in look="panel", pattern, blend, bands, and lk-dock. 2.2.0 adds reading, stuck, mark, cue, and match. They do nothing until you set them.
LayoutKit reads a host --space-* token first. Otherwise the scale is the fluid clamp in --lk-space-fluid-*. --lk-space-static-* is the previous rem scale.
:root {
--lk-space-md: var(--space-md, var(--lk-space-fluid-md));
--space-md: 1rem;
}
| Value | 1.5.0 | 2.0.0 |
|---|---|---|
lg | 50rem | 50rem |
xl | 64rem | 56rem |
2xl | 64rem | |
3xl | 80rem |
Rename a previous width="xl" to width="2xl", or set max-inline-size: 64rem on that element. lk-spread accepts width.
lk-* elements. Use button or a.lk-* elements as headings, lists, tables, forms, landmarks, or controls.reading-flow exists, a reversed row, a dense grid, and spot follow the picture instead. reading="source" opts back out. The switcher does not flip flex-direction when it stacks.lk-scroll-area does not create a tab stop. Set tabindex="0" and a name when the region itself must scroll from the keyboard. Without direction, both axes scroll. direction="vertical" clips inline overflow.lk-menu and lk-disclosure do not invent buttons. The invoker is the first child and must be a button, link, or summary.lk-progress is decorative. It does not replace a status message.prefers-reduced-motion. Scroll buttons, where the browser provides them, do not replace keyboard scrolling.<form action="/settings" method="post">
<lk-stack gap="md">
<label>Name <input name="name"></label>
<button type="submit">Save</button>
</lk-stack>
</form>
<section aria-labelledby="activity">
<h2 id="activity">Recent activity</h2>
<lk-scroll-area max-h="md" direction="vertical">
<ol><li>Order opened</li></ol>
</lk-scroll-area>
</section>
jsx.d.ts teaches TypeScript the known tags and the attributes each one implements. Importing the stylesheet picks up those types. A triple-slash reference works when you do not want compilerOptions.types to replace the automatic @types list.
import "layoutkit-css/layoutkit.css";
/// <reference types="layoutkit-css" />
Current Chrome, Firefox, and Safari cover flex, grid, cascade layers, logical properties, aspect-ratio, and min(). Viewport units step through 100dvh, 100svh, and 100vh. Dividers use color-mix() and fall back to #e5e7eb. A card border uses color-mix() and does not have that second color.
Container queries, :has(), subgrid, scroll snap, and sticky positioning are in current major browsers and still inside @supports. Anchor positioning, anchor-size(), and scroll timelines are not one story. anchor-size() is in current Chrome, Firefox, and Safari. As of November 2026, reading-flow and scroll-state queries are Chromium only. popover="hint" is Chromium and Firefox, not Safari. interpolate-size: allow-keywords is Chromium only among stable engines, and appearance: base-select is Chromium and Safari 27, not Firefox stable. Where the test fails, a disclosure still opens, a select stays the operating-system control, a reversed row keeps source tab order, and a sticky bar stays plain.
No runtime JavaScript, no dependencies, no install scripts, no remote imports, and no network requests from the stylesheet.
npm pack layoutkit-css
tar -tzf layoutkit-css-*.tgz