@a11d/root-css-injector
v0.1.1
Published
A utility for injecting Lit styles into the document head, once or for as long as a component is connected.
Readme
@a11d/root-css-injector
A utility for injecting Lit styles into the document head, once or for as long as a component is connected.
Installation
npm install @a11d/root-css-injectorUsage
import { Component, component, css } from '@a11d/lit'
import { RootCssInjector, RootCssInjectorController } from '@a11d/root-css-injector'
RootCssInjector.inject(css`
:root {
--app-accent-color: teal;
}
`)
@component('app-shell')
export class Shell extends Component {
protected readonly rootCss = new RootCssInjectorController(this, css`body { margin: 0; }`)
}API
| Name | Kind | Description |
| --- | --- | --- |
| RootCssInjector | class | Injects styles into the document head, where they apply to the whole document rather than to a single shadow root. |
| RootCssInjectorController | class | Injects styles into the document head while its host is connected and removes them once it disconnects. |
Links
License
MIT © a11delavar
