Reference · 2.2.0

LayoutKit docs

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.

Install and load CSS

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
npm install layoutkit-css@2.2.0
import
import "layoutkit-css/layoutkit.css";
local file
<link rel="stylesheet" href="/layoutkit.css">

Scope

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.

Non-goals

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.

Semantic HTML first

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

landmarks stay native
<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

meaning is gone
<lk-box>
  <lk-stack>
    <lk-box lk-text="2xl">Dashboard</lk-box>
  </lk-stack>
</lk-box>

lk-text is an attribute, not a tag.

Primitives

Tags in layoutkit.css 2.2.0
TagPurposeCommon attributes
lk-stackVertical 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-rowHorizontal 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-centerCenters 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-boxBlock wrapper. pattern and blend are opt-in.padding, fill, width, flow, sticky, stuck, square, reveal, pattern, blend
lk-cardNeutral padded block.padding, radius, surface, border, width, flow, adapt, reveal
lk-spreadSpace-between row. Accepts width.align, padding, place, width
lk-gridGrid. 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-clusterWrapping group.gap, place
lk-switcherContainer row that stacks below 30rem. Default limit is 4.gap, container, limit, at
lk-sidebarSide and content that wrap on the container.gap, side, container, sticky, stuck, layout
lk-coverMinimum-height column. Put center on the middle child.gap, size
lk-spacerFlexible or fixed space.size
lk-dividerVisual rule. Default color follows currentColor.orientation, thickness
lk-aspect-ratioAspect frame. Replaced children fill it.ratio
lk-scroll-areaBounded scroller. Horizontal direction snaps unless snap="off".direction, max-h, gap, snap, slide, mark, cue
lk-progressScroll progress. Static when timelines are missing. A bare element tracks the viewport.scope
lk-popoverTop-layer panel. Does not set display. popover="hint" is the light tooltip.anchor, match, popover
lk-disclosureLayout for native details and summary. The same name opens one at a time.panel, anchor, side, animate, look
lk-menuInvoker plus lk-popover. The invoker is the first child.anchor, side, match
lk-columnsMulti-column text. Children avoid splitting.cols, gap
lk-frameFull-width grid. The center track is the measure. Side tracks are the gutter.width, padding
lk-bleedSpans a frame. Subgrid returns its children to the column where subgrid exists.padding
lk-dockHover grows an item and its neighbors. :has() reaches the previous item.gap
lk-selectNative select. Custom picker only where appearance: base-select exists.width

Attributes

Attributes name stable layout behavior. They are not a mirror of every CSS property.

Spacing

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-*.

Alignment

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.

Sizing

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.

Grid tracks

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.

Switcher

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.

On by default

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.

Live layouts

These regions are the stylesheet. Resize the window. A browser without a feature keeps the previous layout, because each one is wrapped in @supports.

Container queries

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.

North
South
West
North
South
West

Switcher

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.

Alpha
Beta
One
Two
Three

Sidebar

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.

Scroll-snap

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.

One

First slide

Two

Second slide

Three

Third slide

One child, and a figure

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.

Shore

The text stays inset while the figure runs to the edges.

Subgrid

Keep cols so a browser without subgrid still has a template. Gap is inherited unless you set one.

Name Status Updated Website Ready Today

Sticky side and scroll progress

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.

Popover and disclosure

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.

Filters

Columns and overlay

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.

Under the overlay.

Centered overlay

2.1 additions

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.

Frame

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.

In the column

The measure stays put. Gutters take the rest.

This band is the width of the frame.

Disclosure, dock, and select

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.

Shipping

Orders leave on weekday mornings.

Returns

Opening this closes Shipping.

2.2 additions

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.

Reading order

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.

One Two Three

Stuck title

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.

Current slide and a hint

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.

One

First highlight

Two

Second highlight

Three

Third highlight

Writes the draft on this device.

More below

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.

Frozen helpers

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.

Tokens and widths

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.

space
:root {
  --lk-space-md: var(--space-md, var(--lk-space-fluid-md));
  --space-md: 1rem;
}
width attribute in 2.0.0
Value1.5.02.0.0
lg50rem50rem
xl64rem56rem
2xl64rem
3xl80rem

Rename a previous width="xl" to width="2xl", or set max-inline-size: 64rem on that element. lk-spread accepts width.

Accessibility

  • LayoutKit wraps and arranges semantic HTML. It does not replace it.
  • Do not put click handlers on lk-* elements. Use button or a.
  • Do not use lk-* elements as headings, lists, tables, forms, landmarks, or controls.
  • If a wrapper has no semantic purpose, it usually needs no ARIA. Do not add a role to make it seem semantic.
  • Focus order follows source order, including in Firefox and Safari. Where 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.
  • Reveal and disclosure motion are disabled under prefers-reduced-motion. Scroll buttons, where the browser provides them, do not replace keyboard scrolling.

Examples

Form

markup
<form action="/settings" method="post">
  <lk-stack gap="md">
    <label>Name <input name="name"></label>
    <button type="submit">Save</button>
  </lk-stack>
</form>

Scroll area

markup
<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>

TSX and JSX

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.

types
import "layoutkit-css/layoutkit.css";

/// <reference types="layoutkit-css" />

Browser support

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.

Security

No runtime JavaScript, no dependencies, no install scripts, no remote imports, and no network requests from the stylesheet.

terminal
npm pack layoutkit-css
tar -tzf layoutkit-css-*.tgz
GitHub (opens in a new tab) npm (opens in a new tab) Migration guide