Semantic UI builds on Lit’s directive system to provide reactive data binding, conditional rendering, iteration, and template rendering. These directives are used internally by the template system and are automatically applied based on your template syntax.
Advanced Use - It is not recommended to use these directives directly unless you are building custom template functionality. The template syntax will automatically use the appropriate directive.
Import
Directives
reactiveData
Handles reactive data bindings in templates. Updates the DOM automatically when reactive values change.
Parameters
Name
Type
Required
Description
expression
Object
Yes
Expression configuration object
options
Object
No
Directive options
Expression Object
Property
Type
Required
Description
value
Function
Yes
Function that returns the value
expression
string
Yes
Original template expression
Options Object
Property
Type
Default
Description
ifDefined
boolean
false
Use ifDefined directive
unsafeHTML
boolean
false
Use unsafeHTML directive
Example
reactiveConditional
Handles conditional rendering in templates. Re-renders content when conditions change.
Parameters
Name
Type
Required
Description
options
Object
Yes
Conditional rendering options
Options Object
Property
Type
Required
Description
condition
Function
Yes
Condition evaluation function
content
Function
Yes
Content rendering function
branches
Array
No
Additional else/elseif branches
Branch Object
Property
Type
Required
Description
type
string
Yes
’else’ or ‘elseif’
condition
Function
No
Condition for ‘elseif’
content
Function
Yes
Content rendering function
Example
reactiveEach
Handles array iteration in templates. Re-renders when array content changes.
Parameters
Name
Type
Required
Description
options
Object
Yes
Iteration options
Options Object
Property
Type
Required
Description
over
Function
Yes
Function returning array
content
Function
Yes
Item rendering function
as
string
No
Variable name for each item
Example
renderTemplate
Renders sub-templates within a template. Manages template lifecycle and cleanup.
Parameters
Name
Type
Required
Description
options
Object
Yes
Template rendering options
Options Object
Property
Type
Required
Description
subTemplates
Object
Yes
Available templates
templateName
string
Yes
Name of template to render
getTemplate
Function
No
Dynamic template getter
data
Object
No
Template data context
parentTemplate
Template
No
Parent template reference
Example
Usage in Templates
While these directives are typically used through template syntax, understanding how they work can be helpful for debugging or custom implementations.