Skip to content

Scoped CSS properties overridden when multiple instances of same component #213

Description

@giovannibaldi

I'm using JavaScript to generate scoped CSS based on props passed to the component.

For example, inside of _components/flex-box.webc:

<script webc:type="js" webc:is="style" webc:scoped>
` 
:host {
  display: flex;
  flex-direction: ${direction};
}
`
</script>

The problem is when multiple instances of the same component are on the same page.
Sharing the same CSS class, only the last styles apply.

For example, inside of index.webc:

<flex-box @direction="row"></flex-box>
<flex-box @direction="column"></flex-box>

flex-direction: column; would override flex-direction: row;, assigning the same property to both elements.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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