:on(after())
rulesince 0.10experimentalrequires runtimeRuns once, a delay after the rule becomes active: when its element starts matching the full selector, :when() included.
On this page · 8 sections+−
Syntax
<selector>:on(after(<delay>)) { --<state>: set(...);}:on()Rule · hover any red tokenAn event rule: when the event happens on the matched element (or inside it, for bubbling events), the rule’s state mutations run. The cascade picks one winning mutation per state, per trigger and per element.Reference →
registry syntax: :on(after(delay)) { --state: … }
Parameters
- delay
msorsrequired - Counted from activation.
Effect
No value. The run is a transaction, like an event.
Example
toast.cssreactive
.app { --visible: state(false); }.app .show:on(click) { --visible: set(true); }.toast:when(--visible):on(after(3s)) { --visible: set(false); }state()Function · hover any red tokenMakes each matching element the owner of an independent state with an initial value.Reference →
Behavior
- Leaving the selector, or removal, cancels the timer. Matching again starts a new one. An unrelated state change or a move inside the document does not restart it.
- The deadline is wall-clock: in a hidden tab the browser may run it late, and it then runs once.
- Each run resolves the state's owner again.
- A timer starts one frame after the state change that activates it: the
:when()marker is written in the frame.
Supported contexts
- Unconditional rules and rules with
:when(), classes and attributes in the selector.
Limitations
- No modifiers, and
event()is not available. - Rules cannot depend on
:hover,:focus,:checkedand other states the runtime cannot follow, and cannot be nested in a rule with a state condition. Use a state. - It cannot be combined with other events in
a | b.
Related
Experimental · syntax may change between minor versions