Skip to main content

Key blocks destroy and recreate their contents when the value of an expression changes.

{#key value}
	<div transition:fade>{value}</div>

This is useful if you want an element to play its transition whenever a value changes instead of only when the element enters or leaves the DOM.

Wrap the <span> element in a key block depending on number. This will make the animation play whenever you press the increment button.

We stand with Ukraine. Donate → We stand with Ukraine. Petition your leaders. Show your support.