Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Oct 1, 2024
1 parent bfe431e commit 0153d49
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/data/material/customization/shadow-dom/shadow-dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ const theme = createTheme({
</ThemeProvider>;
```

### 3. CSS theme variables (optional)

If you want to use [CSS theme variables](/material-ui/customization/css-theme-variables/overview/) inside of the shadow DOM, you need to set the selectors for generating the CSS variables:

```diff
const theme = createTheme({
+ cssVariables: {
+ rootSelector: ':host',
+ colorSchemeSelector: 'class',
+ },
components: {
// ...same as above steps
}
})
```

Next, use the `shadowRootElement` as the color scheme node for attaching the class:

```diff
<ThemeProvider
theme={theme}
+ colorSchemeNode={shadowRootElement}
>
```

## Demo

In the example below you can see that the component outside of the shadow DOM is affected by global styles, while the component inside of the shadow DOM is not:
Expand Down

0 comments on commit 0153d49

Please sign in to comment.