Skip to main content

A component can change its category altogether with <svelte:component>. Instead of a sequence of if blocks...

{#if selected.color === 'red'}
{:else if selected.color === 'green'}
{:else if selected.color === 'blue'}

...we can have a single dynamic component:

<svelte:component this={selected.component}/>

The this value can be any component constructor, or a falsy value — if it's falsy, no component is rendered.

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