mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
400 B
24 lines
400 B
6 years ago
|
---
|
||
|
title: Slot fallbacks
|
||
|
---
|
||
|
|
||
|
A component can specify *fallbacks* for any slots that are left empty, by putting content inside the `<slot>` element:
|
||
|
|
||
|
```html
|
||
|
<div class="box">
|
||
|
<slot>
|
||
|
<em>no content was provided</em>
|
||
|
</slot>
|
||
|
</div>
|
||
|
```
|
||
|
|
||
|
We can now create instances of `<Box>` eithout any children:
|
||
|
|
||
|
```html
|
||
|
<Box>
|
||
|
<h2>Hello!</h2>
|
||
|
<p>This is a box. It can contain anything.</p>
|
||
|
</Box>
|
||
|
|
||
|
<Box/>
|
||
|
```
|