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

Styles

Template tag which which can be used with LitElement's styles property to set element styles. For security reasons, only literal string values may be used. To incorporate non-literal values unsafeCSS may be used inside a template string part.

Import

Signature

css(strings, values): CSSResult

Parameters

strings
TemplateStringsArray
values
Array<number | CSSResult>

Import

Methods and properties

new CSSResult(cssText, safeToken): CSSResult

Permalink to constructor View source
Parameters
cssText
string
safeToken
symbol

readonly cssText: string

Permalink to cssText View source

Whether the current browser supports adoptedStyleSheets.

Import

Type

boolean

Wrap a value for interpolation in a css tagged template literal.

Import

Signature

unsafeCSS(value): CSSResult

Parameters

value
unknown

Details

This is unsafe because untrusted CSS text can be used to phone home or exfiltrate data to an attacker controlled site. Take care to only use this with trusted input.

Import

Import

Type

CSSResultOrNative | CSSResultArray

Import

Type

CSSResult | MDN CSSStyleSheet