Component HTML File
Every UI component must have an HTML file with the root tag <template>. API module components (libraries) don’t require an HTML file.
The HTML file follows the naming convention componentName.html, such as myComponent.html.
A component’s HTML file can have a maximum file size of 128 KB (131,072 bytes).
Create the HTML for a Lightning web component declaratively, within the <template> tag. The HTML template element contains your component’s HTML.
1
2<template>
3
4</template>
When a component renders, the <template> tag is replaced with the name of the component, <namespace-component-name>. For example, in the browser console, myComponent renders as <c-my-component>, where c is the default namespace.
The HTML spec mandates that tags for custom elements (components) aren’t self-closing. In other words, custom elements must include separate closing tags. For example, the c-todo-item component nested in this component includes a separate closing </c-todo-item> tag.
1
2<template>
3 <c-todo-item></c-todo-item>
4</template>
Write markup that you may not want to display when the page loads, but that can be rendered at runtime. See Render DOM Elements Conditionally.
Use simple HTML template syntax to render lists. See Render Lists.
Create placeholders in the template that component consumers can replace with content. See Pass Markup into Slots.
This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.