Skip to content

Using IDs and Classes on Custom Components #6773

@Nukiloco

Description

@Nukiloco

Describe the problem

Currently I'm porting over my website application from Lit to Svelte. When assigning a custom component an id/class and using css to position it, i noticed that the style didn't get applied at all. There is many parts in my website where I move child components into certain positions and spots. Obviously a way to bypass it is to give my custom component custom css variables and assign it to the component, though this feels very redundant to do, especially when your website is composed of a lot of components.

As far as I know of, many if not almost all web frameworks allow you to assign custom ids and classes to custom web components.

If there is some alternative way to making this easier, then I haven't found it in the documents, examples, or even the project examples yet.

Describe the proposed solution

Very simple solution is to allow ids and classes to be assigned to custom components.

<CustomComponent id="custom_component"></CustomComponent>

<style>
#custom_component {
  position: relative;
  width: 300px;
  height: 400px;
  top: 500px;
  left: 300px;
  color: blue;
}
</style>

Alternatives considered

I'm not sure of current alternative features currently that I can use.

Importance

would make my life easier

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