Tutorial · 2.2.0

Arrange native HTML.

Every example keeps headings, links, buttons, lists, and landmarks as real elements. The lk-* tags only place them. Upgrading from 1.x? Read MIGRATION.md.

Step 1

Center content

lk-center covers a positioned parent unless overlay="off". Empty states in normal flow use the opt-out. Where safe center exists, content that is wider than the center lines up at the start. Content that fits stays in the middle.

markup
<lk-center overlay="off">
  <section aria-labelledby="empty-heading">
    <h2 id="empty-heading">No results</h2>
  </section>
</lk-center>

No results

Step 2

Stack with a fluid gap

gap="md" uses the fluid space scale. A host --space-md token still wins.

markup
<lk-stack gap="md">
  <p>Summary</p>
  <p>Details</p>
</lk-stack>

Summary

Details

Next steps

Step 3

A header with spread

lk-spread pushes the first and last children apart. The landmark stays a nav.

markup
<lk-spread align="center">
  <a href="/">Logo</a>
  <nav aria-label="Primary">
    <lk-row gap="sm">
      <a href="/">Home</a>
      <a href="/docs">Docs</a>
    </lk-row>
  </nav>
</lk-spread>

Step 4

A grid that knows its width

Fixed cols stack below 32rem because the grid is a container. responsive is auto-fit and does not use that stack. The 16rem frame shows the stack. This card shows the wide grid.

markup
<lk-grid cols="3" gap="md">
  <article><h3>North</h3></article>
  <article><h3>South</h3></article>
  <article><h3>West</h3></article>
</lk-grid>

North

South

West

North

South

West

Step 5

Switcher, from the container

Children sit in a row above 30rem and take the full row below it. at picks another threshold: xs 20rem, sm 24rem, lg 40rem, xl 48rem, 2xl 64rem. Five or more children each take a row unless you set limit.

markup
<lk-switcher gap="md">
  <article><h3>Alpha</h3></article>
  <article><h3>Beta</h3></article>
</lk-switcher>

Alpha

Beta

Alpha

Beta

Step 7

Snap scrolling

A horizontal lk-scroll-area snaps unless snap="off". slide="peek" shows the next item. Give the region a tabindex and a name so it is a keyboard stop.

markup
<lk-scroll-area direction="horizontal" snap slide="peek" tabindex="0" aria-label="Highlights">
  <article><h3>One</h3></article>
  <article><h3>Two</h3></article>
  <article><h3>Three</h3></article>
</lk-scroll-area>

One

First slide

Two

Second slide

Three

Third slide

Step 8

Compose a page

fill grows a wrapper that is itself a flex item. The landmark stays a native main.

App

Content