Form mirror
Type in the field and the preview follows; the Clear button resets both.
experimentalstate()bind():on()event()content
A number controlled entirely through CSS state and events.
Click − or +, or Tab to a button and press Enter or Space.
| name | value | previous | changes |
|---|---|---|---|
| Waiting for the preview to start. | |||
A mutable number. state() declares it on .counter, an :on(click) rule on each button changes it with increment() or decrement(), and content writes it into the <output> as real text.
None for a number that changes on click: CSS has no writable values. Without Reactive CSS this needs a few lines of JavaScript.
<output aria-live="polite"> asks screen readers to announce changes; not verified with a screen reader./* ---- Reactive CSS -------------------------------------------------------------------------- */.counter { --count: state(0); } /* each .counter owns a number */.counter .inc:on(click) { --count: increment(1); }.counter .dec:on(click) { --count: decrement(1); }.counter .value { content: var(--count); } /* the number as real DOM text */Source: site/src/catalog/api/counter/. style.css from its Reactive CSS divider; the layout above it and the shared api.css run but are not shown.
Type in the field and the preview follows; the Clear button resets both.