Signup form
A text field, a select and a checkbox feed a live preview, and Reset clears both.
A menu that opens on click and closes on Escape, on a choice or on a click anywhere else.
Open the menu, choose an item, open it again and press Escape, then open it and click outside.
| name | value | previous | changes |
|---|---|---|---|
| Waiting for the preview to start. | |||
Three ways to close one menu, and focus that goes where the user expects. outside(click) closes the menu on a click anywhere else on the page, Escape closes it, and a choice closes it and records which item was chosen.
The popover attribute with popovertarget gives light dismiss and Escape without a script. Prefer it for a plain menu; this version also records the choice and manages focus.
/* ---- Reactive CSS -------------------------------------------------------------------------- */.dropdown { --open: state(false); --back: state(false); --choice: state("none"); }.dropdown .trigger:on(click) { --open: toggle(); --back: set(false); }/* A choice, Escape or a click anywhere else closes it. */.dropdown li button:on(click) { --choice: set(attr(data-choice)); --open: set(false); --back: set(true); }.dropdown .menu:on(keydown(Escape)) { --open: set(false); --back: set(true); }.dropdown .menu:on(outside(click)) { --open: set(false); }.dropdown .trigger { --attr-aria-expanded: var(--open); }.dropdown:when(--open) ul { display: block; }/* Opening focuses the first item; Escape or a choice returns focus to the button. */.dropdown li:first-child button { focus: when(--open); }.dropdown .trigger { focus: when(--back); }.dropdown .choice { content: var(--choice); }Source: site/src/catalog/interfaces/dropdown/. style.css from its Reactive CSS divider; the layout above it and the shared api.css run but are not shown.
A text field, a select and a checkbox feed a live preview, and Reset clears both.
Three steps with Back and Next buttons, a step list you can click, and aria-current on the current step.
Native checkboxes whose label fades when done, with a short animation when a task is checked or unchecked.