0
0
Svelteframework~10 mins

Layout files (+layout.svelte) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a layout component that wraps page content.

Svelte
<script>
  export let [1];
</script>

<main>
  <slot />
</main>
Drag options to blanks, or click blank then click option'
Adata
Bpage
Ccontent
Dchildren
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'children' which is common in React but not in SvelteKit.
Using 'page' which refers to the $page store, not a prop.
Using 'content' which is not a standard prop here.
2fill in blank
medium

Complete the code to include a navigation bar inside the layout.

Svelte
<nav>
  <a href="/">Home</a>
  <a href="/about">About</a>
</nav>

[1]
Drag options to blanks, or click blank then click option'
A<content />
B{page}
C<slot />
D<children />
Attempts:
3 left
💡 Hint
Common Mistakes
Using React-like {page} or <children /> which are not valid in Svelte.
Using <content /> which does not exist in Svelte.
3fill in blank
hard

Fix the error in the layout script to correctly import a component.

Svelte
<script>
  import Header from '[1]';
</script>

<Header />
<slot />
Drag options to blanks, or click blank then click option'
A./Header.svelte
BHeader.svelte
C/Header.svelte
Dheader.svelte
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the ./ prefix causes import errors.
Using uppercase or lowercase inconsistently in file names.
4fill in blank
hard

Fill both blanks to create a layout that applies a CSS class and includes page content.

Svelte
<div class="[1]">
  [2]
</div>
Drag options to blanks, or click blank then click option'
Alayout-container
B<slot />
C<content />
Dcontainer
Attempts:
3 left
💡 Hint
Common Mistakes
Using <content /> which is not valid in Svelte.
Leaving the class attribute empty or invalid.
5fill in blank
hard

Fill all three blanks to create a layout with a header, main content slot, and footer.

Svelte
<header>[1]</header>
<main>[2]</main>
<footer>[3]</footer>
Drag options to blanks, or click blank then click option'
A<Header />
B<slot />
C<Footer />
D<Content />
Attempts:
3 left
💡 Hint
Common Mistakes
Using <Content /> which is not a standard Svelte slot or component.
Forgetting to include the <slot /> for page content.