You're viewing docs for an older version of Lit. Click here for the latest version.

Styles

Applies the given styles to a shadowRoot. When Shadow DOM is available but adoptedStyleSheets is not, styles are appended to the shadowRoot to mimic spec behavior. Note, when shimming is used, any styles that are subsequently placed into the shadowRoot should be placed before any shimmed adopted styles. This will match spec behavior that gives adopted sheets precedence over styles in shadowRoot.

Import

import { adoptStyles } from 'lit';

Signature

adoptStyles(renderRoot, styles): void

Parameters

renderRoot
MDN ShadowRoot
styles
Array<CSSResultOrNative>

A template literal tag which can be used with LitElement's styles property to set element styles.

Import

import { css } from 'lit';

Signature

css(strings, values): CSSResult

Parameters

strings
TemplateStringsArray
values
Array<number | CSSResultGroup>

Details

For security reasons, only literal string values and number may be used in embedded expressions. To incorporate non-literal values unsafeCSS may be used inside an expression.

A container for a string of CSS text, that may be used to create a CSSStyleSheet.

Import

import { CSSResult } from 'lit';

Details

CSSResult is the return value of css-tagged template literals and unsafeCSS(). In order to ensure that CSSResults are only created via the css tag and unsafeCSS(), CSSResult cannot be constructed directly.

Methods and properties

readonly cssText: string

Permalink to cssText View source