Accordion
Each item opens and closes on its own, and its button reports the state with aria-expanded.
A billing switch changes the price and shows the annual saving, with role="switch" kept in sync.
Click the switch, or focus it and press Space.
| name | value | previous | changes |
|---|---|---|---|
| Waiting for the preview to start. | |||
A switch with the right semantics. The button has role="switch", and --attr-aria-checked keeps its aria-checked equal to the state, so assistive technology announces “on” and “off”. The price is DOM text picked with when().
A checkbox styled as a switch: :checked ~ .price can show the other price if both are in the HTML. Reactive CSS keeps one price element and the ARIA state in sync.
/* ---- Reactive CSS -------------------------------------------------------------------------- */.billing { --annual: state(false); }.billing .switch:on(click) { --annual: toggle(); }/* role="switch" needs aria-checked: written from the state. */.billing .switch { --attr-aria-checked: var(--annual); }.billing .price { content: when(--annual, "$96 / year", "$10 / month"); }.billing:when(--annual) .saving { display: inline; }Source: site/src/catalog/interfaces/pricing-toggle/. style.css from its Reactive CSS divider; the layout above it and the shared api.css run but are not shown.
Each item opens and closes on its own, and its button reports the state with aria-expanded.
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.