Dropdown menu
A menu that opens on click and closes on Escape, on a choice or on a click anywhere else.
Tabs selected by click or arrow keys, with the ARIA tab pattern written from one state.
Click a tab. Or press Tab to reach the selected tab and use the left and right arrow keys.
| name | value | previous | changes |
|---|---|---|---|
| Waiting for the preview to start. | |||
A complete tab set from one number state. A click writes the tab’s position, arrow keys cycle it, and every visible and accessible detail reads it: the selected tab, its aria-selected and tabindex, the panel, and the focus.
None for the selection itself. Native HTML has no tab element; <details name> gives an exclusive accordion, not tabs.
cycle(1, 2, 3) and one focus rule per tab)./* ---- Reactive CSS -------------------------------------------------------------------------- */.tabs { --active: state(1); }.tabs .tab:on(click) { --active: set(sibling-index()); }/* Arrow keys move the selection, wrapping at the ends. prevent() keeps the page from scrolling. */.tabs [role="tablist"]:on(keydown(ArrowRight), prevent()) { --active: cycle(1, 2, 3); }.tabs [role="tablist"]:on(keydown(ArrowLeft), prevent()) { --active: cycle(3, 2, 1); }/* The ARIA tab pattern: one selected tab, the only one in the Tab order. */.tabs .tab { --attr-aria-selected: false; --attr-tabindex: -1; }.tabs .tab:nth-var(--active) { --attr-aria-selected: true; --attr-tabindex: 0; color: var(--ink); border-bottom-color: currentColor; }/* Focus follows the selection after a key press. */.tabs .tab:nth-child(1) { focus: when(--active == 1); }.tabs .tab:nth-child(2) { focus: when(--active == 2); }.tabs .tab:nth-child(3) { focus: when(--active == 3); }.tabs .panel:nth-var(--active) { display: block; }Source: site/src/catalog/interfaces/tabs/. style.css from its Reactive CSS divider; the layout above it and the shared api.css run but are not shown.
A menu that opens on click and closes on Escape, on a choice or on a click anywhere else.
One keyword state cycles through three themes, and the page colors and the button label follow it.
A text field, a select and a checkbox feed a live preview, and Reset clears both.