Skip to content
astrostyle v0.6.2

Navigation

Ways to move around a site. The breadcrumb is plain HTML and CSS; pagination and tabs get their behavior from small JavaScript modules, wired here by autoInit().

<nav class="ap-c-breadcrumb" aria-label="Breadcrumb">
  <ol class="ap-c-breadcrumb__list">
    <li class="ap-c-breadcrumb__item"><a class="ap-c-breadcrumb__link" href="/fleet">Fleet</a></li>
    <li class="ap-c-breadcrumb__item"><a class="ap-c-breadcrumb__link" aria-current="page">Night Heron</a></li>
  </ol>
</nav>

The last item carries aria-current="page". Separators are generated content that screen readers skip; change them with --ap-breadcrumb-separator (a CSS string). Long paths wrap.

Tokens of breadcrumb: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-breadcrumb-gapvar(--ap-space-sm)
--ap-breadcrumb-link-colorvar(--ap-text-muted)
--ap-breadcrumb-link-hover-colorvar(--ap-link)
--ap-breadcrumb-current-colorvar(--ap-text)
--ap-breadcrumb-separator"/"
--ap-breadcrumb-separator-colorvar(--ap-text-subtle)

Pagination 02

Buttons: pick a page, ap:page reports it here.

Links (data-ap-href): they navigate like any link; at either end the step is disabled.

<!-- links: the server renders each page -->
<nav data-ap-pagination data-ap-page="2" data-ap-count="12" data-ap-href="?page={page}" aria-label="Log pages"></nav>

<script type="module">
  import { autoInit, createPagination } from 'astrostyle/js'
  autoInit(document)

  // buttons: load the page yourself
  const pages = createPagination(nav, { page: 1, count: 12 })
  nav.addEventListener('ap:page', (event) => loadPage(event.detail.page))
</script>

The window keeps the same number of items while you page, so the control never jumps. Options: siblings, boundaries, labels. Cancel ap:page on links to route on the client.

Tokens of pagination: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-pagination-gapvar(--ap-space-xxs)
--ap-pagination-sizevar(--ap-size-control)
--ap-pagination-radiusvar(--ap-radius-pill)
--ap-pagination-fgvar(--ap-text)
--ap-pagination-hover-bgcolor-mix(in oklab, var(--ap-text) 8%, transparent)
--ap-pagination-current-bgvar(--ap-accent)
--ap-pagination-current-fgvar(--ap-on-accent)
--ap-pagination-gap-colorvar(--ap-text-subtle)

Tabs 03

Vega, Okonkwo, Hasegawa and Marlowe are aboard.

Twelve plasma cells, one Medusa spike, two drone frames.

Shields and life support online; cloak offline.

Locked.

Left the Corsair dock at 07:40.

Three jumps, one ambush.

Forty-two cycles of records.

<div class="ap-c-tabs" data-ap-tabs>
  <div class="ap-c-tabs__list" aria-label="Ship sections">
    <button class="ap-c-tabs__tab" type="button">Crew</button>
    <button class="ap-c-tabs__tab" type="button" aria-selected="true">Cargo</button>
  </div>
  <section class="ap-c-tabs__panel">…</section>
  <section class="ap-c-tabs__panel">…</section>
</div>

Keyboard: ←/→ move between tabs in reading order (skipping disabled ones; right to left, ← is next), Home/End jump to the ends, Tab goes to the panel. The second set uses manual activation (data-ap-tabs="manual"): arrows move focus, Enter selects. Without JavaScript every panel is shown.

Tokens of tabs: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-tabs-gapvar(--ap-space-xxs)
--ap-tabs-border-colorvar(--ap-border-subtle)
--ap-tabs-tab-fgvar(--ap-text-muted)
--ap-tabs-tab-hover-fgvar(--ap-text)
--ap-tabs-tab-hover-bgcolor-mix(in oklab, var(--ap-text) 6%, transparent)
--ap-tabs-selected-fgvar(--ap-text)
--ap-tabs-indicator-colorvar(--ap-accent)
--ap-tabs-indicator-sizevar(--ap-border-width-strong)
--ap-tabs-panel-paddingvar(--ap-space-lg)