consul/ui/packages/consul-ui/app/helpers/adopt-styles.mdx
John Cowen 25f3ebd66a
ui: CustomElement component (#12451)
Builds on attach-shadow, adopt-styles and ShadowTemplate, this commit adds ShadowHost and finally CustomElement.

CustomElement is a renderless component to help with the creation of native HTML Custom Elements along with runtime type checking and self-documentation for attributes, slots, cssprops and cssparts. As you will probably see there is a little more work to come here. But in the same breath, everything would be fine to go in as is.
2022-03-07 09:51:47 +00:00

29 lines
600 B
Plaintext

# adopt-styles
Adopt/apply given styles to a `ShadowRoot` using constructable styleSheets if supported
```hbs preview-template
<div
{{attach-shadow (set this 'shadow')}}
>
{{#if this.shadow}}
{{#in-element this.shadow}}
{{adopt-styles this.shadow (css '
:host {
background-color: red;
width: 100px;
height: 100px;
}
')}}
{{/in-element}}
{{/if}}
</div>
```
## Positional Arguments
| Argument | Type | Default | Description |
| --- | --- | --- | --- |
| `params` | `[ShadowRoot, (CSSResultGroup \| CSSResultGroup[])]` | | |