Skip to content

Add the ability to add classes to slots #4443

Closed
@tiddle

Description

@tiddle

Is your feature request related to a problem? Please describe.
I want to be able to add classes to slots so that i can style them directly.

Describe the solution you'd like

App.svelte

<MyComponent>
    <ul slot="list">
       ...
    </ul>
</MyComponent>

MyComponent.svelte

<slot name="list" class="my-list-style">
   <p>No items found</p>
</slot>

Describe alternatives you've considered
This alternative works, but i still can't style the ul in my example correctly and it feels like it renders the fallback slot functionality useless.

{#if list.length}
<div class="my-list-style">
   <slot name="list" />
</div>
{:else}
<p>No items found</p>
{/if}

How important is this feature to you?
There are work arounds, but nothing clean. I just feel like this should be functionality that should be part of the slot feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions