Skip to content

Class directive for components #5236

Closed
Closed
@AhmadMayo

Description

@AhmadMayo

Is your feature request related to a problem? Please describe.
Svelte components have the look and feel of vanilla html. Feature requests like #3852 - I'm assuming - supports the argument that svelte developers wants to keep components' props as close to html attributes as possible. Having class directives working with components in the same way they work with html elements would be a nice feature to have for component libraries' developers.

Describe the solution you'd like

<MyComponent class:first class="second" class={condition ? classVar : ''} />

and may be access the compiled prop through $$class // "first second valueOfClassVar" - may be even exclude it from $$restProp?

Describe alternatives you've considered
passing the calculated string to a custom prop (className for example), and let the user handle the logic to calculate the end result of the string.

How important is this feature to you?
Not very important, but I think it would be nice to have it.

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions