DEV Community

Pooja DebRoy
Pooja DebRoy

Posted on

Slot Composition

We used slots when creating our learning cards for project 2. One example of slotting we used is the content for the card getting passed through our frame and into our scaffold of our final card. Here is a code snippet of the slots we used for our card:

render() {
    return html`
        <card-header slot="banner" type="${this.type}">
            aria-label="Main header"
            style="font-family: 'Open Sans', sans-serif; font-weight: 300;"
            <slot name="header">${this.heading}</slot>
            aria-label="Sub Header"
            style='font-family: "Open Sans", sans-serif; font-weight: 500;'
            <slot name="subheader">${this.subheading}</slot>
          style="margin-right: 5em; min-height: 40px; display: flex;"
Enter fullscreen mode Exit fullscreen mode

As you can see, there are slots allocated for the header, sub-header, as well as content. Each slot contains the font, font weight, and text size depending on the specific portion of the card frame. We used slotting to pass the header, icon, and frame with content to the final card.

Here is a link to our repo for LearningCard:

Week 9 blog post 8

Top comments (0)