Slots in the Svelte SDK
Developer preview
This feature is in developer preview. Use with caution as it may change unexpectedly. For more information, contact us.
UniformSlot renders the child components in one named slot:
<UniformSlot name="content" />
name is required. The slot renders nothing when that name is missing on the component, and it logs a warning in development.
Component with slots#
This page component renders three named slots:
<!-- src/lib/components/Page.svelte -->
<script lang="ts">
import { UniformSlot } from '@uniformdev/canvas-svelte';
import type { ComponentProps } from '@uniformdev/canvas-svelte';
interface Props extends ComponentProps<{
title?: string;
description?: string;
}> {}
let { title, description, component }: Props = $props();
</script>
<svelte:head>
{#if title}
<title>{title}</title>
{/if}
{#if description}
<meta name="description" content={description} />
{/if}
</svelte:head>
<main>
<header>
<UniformSlot name="header" />
</header>
<UniformSlot name="content" />
<footer>
<UniformSlot name="footer" />
</footer>
</main>
UniformSlot props#
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | Required. The slot name to render | |
resolveRenderer | RenderComponentResolver | inherited | Override the component resolver for this slot's children |
wrapperComponent | Component | undefined | A Svelte component that wraps the slot's children |
Empty slot placeholder#
UniformSlot supports an emptyPlaceholder snippet for when the slot has no items:
<UniformSlot name="sidebar">
{#snippet emptyPlaceholder()}
<p class="text-gray-400 italic">Drag components here</p>
{/snippet}
</UniformSlot>