W3C home > Mailing lists > Public > public-css-archive@w3.org > June 2020

Re: [csswg-drafts] [css-shadow-parts] Can I use ::slotted and ::part together? (#5161)

From: Rúnar Berg Baugsson Sigríðarson via GitHub <sysbot+gh@w3.org>
Date: Fri, 05 Jun 2020 16:35:29 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-639616271-1591374928-sysbot+gh@w3.org>
Note that I was only experimenting, there are other ways of achieving my goal. E.g. my custom element could dynamically set a property on the child custom element and then I can just move the rules to the shadow styles of the slotted element.

What I ended up doing though is just export a global stylesheet with my library and moved the rules to there:

```html
<my-element>Here the part has a default style</my-element>
<my-container>
  <my-element>
    A shadow part is styled differently because we are a slotted child of
    <code>&lt;my-container&gt;</code>.
  <my-element>
</my-container>
```

```css
/* exported global stylesheet */
my-container my-element::part(my-shadow-part) {
  /* ... */
}
```

-- 
GitHub Notification of comment by runarberg
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5161#issuecomment-639616271 using your GitHub account
Received on Friday, 5 June 2020 16:35:31 UTC

This archive was generated by hypermail 2.4.0 : Thursday, 24 March 2022 20:27:12 UTC