Containers
Dialogs, drawers, accordions, tooltips and menus hold content that comes and goes; tables, lists, dividers, key caps and skeletons arrange and stand in for it. Dialogs, drawers, tooltips and menus are native <dialog> and popover elements with small JavaScript modules; everything else is HTML and CSS.
Dialog 01
Close a dialog: ap:close reports its return value here.
<button class="ap-c-button" type="button" data-ap-dialog-open="jump">Jump</button>
<dialog class="ap-c-dialog" id="jump" aria-labelledby="jump-title" data-ap-dialog>
<header class="ap-c-dialog__header">
<h2 class="ap-c-dialog__title" id="jump-title">Jump to sector 7G?</h2>
</header>
<div class="ap-c-dialog__body">…</div>
<footer class="ap-c-dialog__footer">
<button class="ap-c-button" type="button" data-ap-dialog-close value="cancel">Cancel</button>
</footer>
</dialog>
import { createDialog } from 'astrostyle/js/dialog'
const jump = createDialog(document.querySelector('#jump'), { dismissible: true })
jump.element.addEventListener('ap:close', (event) => console.log(event.detail.returnValue))
A native modal dialog: the page behind is inert and Escape closes it. The module adds openers (data-ap-dialog-open), close buttons whose value becomes the return value, backdrop close, focus return and the ap:open and ap:close events.
| Token | Default |
|---|---|
--ap-dialog-bg | var(--ap-bg) |
--ap-dialog-fg | var(--ap-text) |
--ap-dialog-border-color | var(--ap-border) |
--ap-dialog-radius | var(--ap-radius-card) |
--ap-dialog-shadow | var(--ap-elevation-overlay) |
--ap-dialog-width | 32rem |
--ap-dialog-padding | var(--ap-space-xl) |
--ap-dialog-gap | var(--ap-space-lg) |
--ap-dialog-edge | var(--ap-space-lg) |
--ap-dialog-duration | var(--ap-duration-base) |
Drawer 02
<dialog class="ap-c-drawer" id="filters" aria-labelledby="filters-title" data-ap-dialog>
<header class="ap-c-drawer__header">…</header>
<div class="ap-c-drawer__body">…</div>
<footer class="ap-c-drawer__footer">…</footer>
</dialog>
A dialog along the full height of the end edge; --start moves it to the start edge. Same module, same behavior. It takes the full width on narrow screens.
| Token | Default |
|---|---|
--ap-drawer-bg | var(--ap-bg) |
--ap-drawer-fg | var(--ap-text) |
--ap-drawer-border-color | var(--ap-border) |
--ap-drawer-shadow | var(--ap-elevation-overlay) |
--ap-drawer-width | 24rem |
--ap-drawer-padding | var(--ap-space-xl) |
--ap-drawer-gap | var(--ap-space-lg) |
--ap-drawer-start | auto |
--ap-drawer-end | 0 |
--ap-drawer-offset | var(--ap-space-xl) |
--ap-drawer-duration | var(--ap-duration-slow) |
Accordion 03
How far can the ship jump?
Three sectors per cycle, two with a full hold.
Who can pilot it?
Anyone with a license and a steady hand.
What happens when the drive overheats during a jump that was already planned?
The jump is cancelled and the drive cools for one cycle.
<details class="ap-c-accordion" name="faq">
<summary class="ap-c-accordion__summary">How far can the ship jump?</summary>
<div class="ap-c-accordion__body">…</div>
</details>
Native <details>, no JavaScript. With the same name, only one opens at a time.
| Token | Default |
|---|---|
--ap-accordion-border-color | var(--ap-border-subtle) |
--ap-accordion-summary-fg | var(--ap-text) |
--ap-accordion-summary-hover-bg | color-mix(in oklab, var(--ap-text) 6%, transparent) |
--ap-accordion-chevron-color | var(--ap-accent) |
--ap-accordion-padding-inline | var(--ap-space-sm) |
--ap-accordion-body-padding | var(--ap-space-sm) var(--ap-space-sm) var(--ap-space-lg) |
Table 04
| Item | Category | Qty | Value |
|---|---|---|---|
| Plasma cells | Equipment | 12 | 480 |
| Medusa spike | Hacks | 1 | 1,150 |
| Drone frame | Drones | 2 | 900 |
| Ration packs | Supplies | 40 | 120 |
| Name | Role | Level |
|---|---|---|
| Vega | Pilot | 4 |
| Okonkwo | Engineer | 3 |
<div class="ap-c-table" role="region" aria-labelledby="manifest" tabindex="0">
<table>
<caption id="manifest">Manifest, cycle 7</caption>
…
</table>
</div>
The class goes on a focusable region around the table, so a wide table scrolls sideways with the keyboard too. --striped and --compact change the look; ap-c-table__numeric aligns numbers to the end.
| Token | Default |
|---|---|
--ap-table-border-color | var(--ap-border-subtle) |
--ap-table-radius | var(--ap-radius-control) |
--ap-table-head-bg | var(--ap-surface-1) |
--ap-table-stripe-bg | transparent |
--ap-table-cell-padding-block | var(--ap-space-sm) |
--ap-table-cell-padding-inline | var(--ap-space-md) |
List 05
- Vega
- Okonkwo
- Hasegawa
<ul class="ap-c-list">
<li class="ap-c-list__item">Vega <span class="ap-c-list__meta">Pilot</span></li>
<li class="ap-c-list__item"><a class="ap-c-list__link" href="/sectors/7g">Sector 7G</a></li>
</ul>
A row can hold one link or button that fills it. aria-current marks the current item; --plain drops the hairlines.
| Token | Default |
|---|---|
--ap-list-divider-color | var(--ap-border-subtle) |
--ap-list-gap | var(--ap-space-md) |
--ap-list-padding-block | var(--ap-space-sm) |
--ap-list-padding-inline | var(--ap-space-sm) |
--ap-list-meta-color | var(--ap-text-muted) |
--ap-list-hover-bg | color-mix(in oklab, var(--ap-text) 6%, transparent) |
Divider 06
<hr class="ap-c-divider">
<div class="ap-c-divider">Or</div>
An <hr> is announced as a separator; a labelled divider reads only its label.
| Token | Default |
|---|---|
--ap-divider-color | var(--ap-border) |
--ap-divider-width | var(--ap-border-width-hairline) |
--ap-divider-gap | var(--ap-space-md) |
--ap-divider-label-color | var(--ap-text-muted) |
Keyboard key 07
Press Ctrl + K to search, Esc to close, ↑ ↓ to move.
<kbd class="ap-c-kbd">Ctrl</kbd> + <kbd class="ap-c-kbd">K</kbd>
| Token | Default |
|---|---|
--ap-kbd-bg | var(--ap-surface-1) |
--ap-kbd-fg | var(--ap-text) |
--ap-kbd-border-color | var(--ap-border-strong) |
--ap-kbd-radius | var(--ap-radius-control) |
Skeleton 08
<div role="group" aria-busy="true" aria-label="Loading crew">
<span class="ap-c-skeleton ap-c-skeleton--circle"></span>
<span class="ap-c-skeleton" style="--ap-skeleton-inline-size: 60%"></span>
<span class="ap-c-skeleton ap-c-skeleton--block"></span>
</div>
A text line by default, --block for media, --circle for avatars. Mark the loading region with role="group", aria-busy="true" and a name; --ap-skeleton-duration: 0s stops the pulse.
| Token | Default |
|---|---|
--ap-skeleton-bg | color-mix(in oklab, var(--ap-text) 10%, transparent) |
--ap-skeleton-radius | var(--ap-radius-control) |
--ap-skeleton-inline-size | 100% |
--ap-skeleton-block-size | 1em |
--ap-skeleton-duration | calc(var(--ap-duration-slow) * 5) |
Tooltip 09
<button class="ap-c-button ap-c-button--icon" type="button" aria-labelledby="scan-tip" data-ap-tooltip="scan-tip">…</button>
<span class="ap-c-tooltip" id="scan-tip" role="tooltip" popover="manual">Long-range scan</span>
Hover or tab to the buttons. A popover in the top layer, placed above the trigger (below when there is no room) by createTooltip(); Escape hides it. Link it yourself: aria-labelledby for icon buttons, aria-describedby for extra hints.
| Token | Default |
|---|---|
--ap-tooltip-bg | var(--ap-text) |
--ap-tooltip-fg | var(--ap-bg) |
--ap-tooltip-radius | var(--ap-radius-control) |
--ap-tooltip-padding-block | var(--ap-space-xs) |
--ap-tooltip-padding-inline | var(--ap-space-sm) |
--ap-tooltip-max-width | 18rem |
--ap-tooltip-duration | var(--ap-duration-fast) |
Menu 10
<button class="ap-c-button" type="button" data-ap-menu="ship-menu">Ship</button>
<div class="ap-c-menu" id="ship-menu" popover>
<button class="ap-c-menu__item" type="button" value="rename">Rename</button>
<div class="ap-c-menu__separator" role="separator"></div>
<button class="ap-c-menu__item ap-c-menu__item--danger" type="button" value="scrap">Scrap</button>
</div>
Open it with a click or ↓, move with the arrows, type a letter to jump, Esc to close. A click outside closes it too.
| Token | Default |
|---|---|
--ap-menu-bg | var(--ap-bg) |
--ap-menu-fg | var(--ap-text) |
--ap-menu-border-color | var(--ap-border) |
--ap-menu-radius | var(--ap-radius-control) |
--ap-menu-shadow | var(--ap-elevation-overlay) |
--ap-menu-min-width | 12rem |
--ap-menu-padding | var(--ap-space-xs) |
--ap-menu-item-hover-bg | color-mix(in oklab, var(--ap-text) 8%, transparent) |
--ap-menu-danger-fg | var(--ap-danger-text) |