The html tag returns a description of the DOM to render as a value. It is lazy, meaning no work is done until the template is rendered. When rendering, if a template comes from the same expression as a previously rendered result, it's efficiently updated instead of replaced.
A sentinel value that signals a ChildPart to fully clear its content.
Import
import { nothing } from'lit';
Type
symbol
Details
constbutton=html`${
user.isAdmin
?html`<button>DELETE</button>`
:nothing
}`;
Prefer using nothing over other falsy values as it provides a consistent behavior between various expression binding contexts.
In child expressions, undefined, null, '', and nothing all behave the same and render no nodes. In attribute expressions, nothingremoves the attribute, while undefined and null will render an empty string. In property expressions nothing becomes undefined.
The svgtag function should only be used for SVG fragments, or elements that would be contained inside an <svg> HTML element. A common error is placing an <svg>element in a template tagged with the svg tag function. The <svg> element is an HTML element and should be used within a template tagged with the html tag function.
In LitElement usage, it's invalid to return an SVG fragment from the render() method, as the SVG fragment will be contained within the element's shadow root and thus cannot be used within an <svg> HTML element.