Current section: Slots 30 exercises
Problem

Generic Slot Components

Loading exercise

Transcript

00:00 You'll notice right now our toggle has this label that we want to associate our toggle button to, so I should be able to click on party mode and have it toggle back and forth, which I do. I am able to do that, and this is because I'm creating my own use ID,

00:17 and I don't want to have to do that. I want the toggle to provide a slot for a label, and so if a label shows up, then it gets the proper HTML4. I want the toggle button to get that generated ID also, and so your job in this exercise is to make that happen. By the end of it, we should be able to just use this label component because it is going to consume

00:38 that label slot, and so the toggle needs to expose a label slot, and then you can, from there, you should just be able to use the label directly, and this is where we get into, okay, so why are slots so valuable, and it's because you can use them to create components that can be reused across lots of different compound components, so let's get into it.