Overview
Mates re-exports common lit-html directives from the mates package so you do not need a separate lit-html import. Use them in the binding positions they support (classMap in class=, ifDefined in attribute position, etc.).
For dynamic inline styles, prefer the Mates element directive style({…}) (see /docs/directives/attr-style) over stringly style= interpolation. lit-html’s cache directive is exported as litCache to avoid clashing with other cache APIs in Mates.
lit-html vs Mates element directives
|
Directive
|
Kind
|
Notes
|
|---|---|---|
classMap
| lit — class= | Use as class=${classMap({…})}. |
classes
| Mates — element | Use as ${classes({…})} inside the tag. See class-style. |
style()
| Mates — element | Property map with conditional tuples — not lit-html styleMap. |
litCache
| lit — cache | Re-exported as litCache (lit-html cache). |
Directives: ifDefined, classMap
Directives are special values you embed in html`` expressions. classMap accepts plain objects and efficiently applies only the classes that changed. ifDefined removes an attribute entirely when the value is undefined.
live() for drifted inputs
live(value) forces the property write every render — useful when the DOM may diverge from the bound value (e.g. user-edited inputs reset from state).