Reference › Templates

Template syntax

Everything you can write in a .tscl file, with links to the guide.

SyntaxWhat it doesGuide
@input name: Type = defaulta typed inputInputs
@import name from './x.tscl'use a componentComponents
@import { a } from './x.ts'import dataComponents
@import type { T } from './x'import types for inputsInputs
{{ expr }}print a value, escapedHoles
[name]="expr", name="a {{ b }}"bind an attribute or a component inputAttributes
(event)="handler"handle an event (islands)Islands
@if (a) { } @else if (b) { } @else { }conditional branchesConditionals
@for (x of xs; track x.id) { } @empty { }repeat contentLists
<slot />, <slot name="x">fallback</slot>where wrapped content goesSlots
@slot('x') { }fill a named slotSlots
verbatim attributeshow content as textVerbatim
<script> … </script>make a component interactiveState
<script inline> … </script>a script written out as is, run where it standsStyles
<style> … </style>, <style global>the component's CSS, scoped (or global)Styles
{{-- comment --}}a template comment, removed from the output