Documents v0.9.0 · previews run the real runtime · experimental features are marked exp

pick()

functionsince 0.1requires runtime

One of its values at random, per element.

On this page · 9 sections+

Syntax

pick(<value>, <value>, …)

registry syntax: pick(value, ...)

Parameters

valuescomma-free valuesone or more
Values can contain reactive calls.

Return value

One of the values.

Example

.die {  --roll: on(click, random(1, 6, by 1));  counter-reset: n var(--roll);}.die::before {  content: counter(n);}.greet {  --word: on(click, pick("Hello", "Hi", "Hey"));}.greet::after {  content: var(--word);}
on()Function · hover any red tokenRe-evaluates an expression each time an event fires on the element. The value function, not the :on() event rule.Reference →
Resultnative buttons
waiting for interaction

Behavior

  • Static unless inside live(), on() or an :on() mutation, where a new value is picked at each event (see `pick()` in state()).

Supported contexts

  • Any value.

Limitations

  • Values can’t contain top-level commas.

Examples

Experimental · syntax may change between minor versions