Skip to content

Vue-like component class bindings #14762

@Freeplayg

Description

@Freeplayg

Describe the problem

Currently, if I want to give a svelte component a CSS class, i need to export a "className" prop so that I can reference it in the parent component. This doesn't work with scoped component styles, and I need to rely on :global() which does not seem like a good practice as it can affect other components. And I also want to avoid creating unnecessary wrapper elements for performance and CSS reasons.

Describe the proposed solution

Vue lets you bind the class property to an element in the component, so you can then use it in the parent component like a regular element. This would avoid needing to export the prop as "className", and would work with CSS scoping without needing to rely on :global().

https://vuejs.org/guide/essentials/class-and-style#with-components

Importance

nice to have

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