{#key ...}
{#key expression}...{/key}Key blocks destroy and recreate their contents when the value of an expression changes. When used around components, this will cause them to be reinstantiated and reinitialised:
{#key value}
<Component />
{/key}It’s also useful if you want a transition to play whenever a value changes:
{#key value}
<div transition:fade>{value}</div>
{/key}You can track multiple values via an array — this component will be recreated when any of a, b or c change, because they will cause the array itself to be recomputed:
{#key [a, b, c]}
<Component />
{/key}Edit this page on GitHub llms.txt
previous next