0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00
svelte/documentation/tutorial/14-composition/02-slot-fallbacks/text.md

25 lines
406 B
Markdown
Raw Normal View History

2019-03-10 14:30:29 +01:00
---
title: Slot fallbacks
---
A component can specify _fallbacks_ for any slots that are left empty, by putting content inside the `<slot>` element:
2019-03-10 14:30:29 +01:00
```svelte
2019-03-10 14:30:29 +01:00
<div class="box">
<slot>
<em>no content was provided</em>
</slot>
</div>
```
2019-04-23 06:35:50 +02:00
We can now create instances of `<Box>` without any children:
2019-03-10 14:30:29 +01:00
```svelte
2019-03-10 14:30:29 +01:00
<Box>
<h2>Hello!</h2>
<p>This is a box. It can contain anything.</p>
</Box>
<Box />
2019-04-23 06:35:50 +02:00
```