Ready to get started?

Join Adocasts+ for $8/mo or sign into your account to get access to all of our lessons.

EdgeJS Components #2.4

Main Slot, Named Slots, and Slot Scopes

In this lesson, we'll learn all about the main slot, how to define and use named slots, as well as passing state information from within our components to our slots using slot scopes.

So lastly, before we actually move on to creating our components, let's cover slots. Slots allow us to insert specific HTML content into designated areas within our components.

The Main Slot

First, let's understand the main slot, which we've already touched upon in our app layout. Anything enclosed between the component's start and end tags is rendered as the default slot.

@layout.app({ title: request.params().name }) {{-- 👈 start tag --}}

  Our main slot content {{-- 👈 main slot --}}

@end {{-- 👈 end tag --}}
Copied!

The main slot is accessible in the component by encompassing await $slots.main() with three curly braces. Remember, three curly braces allow us to plop raw HTML within EdgeJS.

Ready to get started?

Join Adocasts+ for $8/mo or sign into your account to get access to all of our lessons.

Join The Discussion! (0 Comments)

Please sign in or sign up for free to join in on the dicussion.