<c-slot> passes a block of HTML into a component under a name. Inside the component it's a variable holding rendered, safe HTML.
<c-card>
<c-slot name="header">
<h2>Weather</h2>
</c-slot>
Sunny, 23°
</c-card>
{% cotton card %}
{% cotton:slot header %}
<h2>Weather</h2>
{% endcotton:slot %}
Sunny, 23°
{% endcotton %}
<div class="card">
<div class="card-header">{{ header }}</div>
{{ slot }}
</div>
<c-slot> goes between a component's tags. It can be wrapped in HTML or in template logic like {% if %}. Using it outside any component is an error.{{ slot }}.name="leading-icon" becomes {{ leading_icon }}.<c-vars /> key takes precedence over the var's default.Slots are plain variables, so {% if %} works:
{% if header %}
<div class="card-header">{{ header }}</div>
{% endif %}
{% cotton:slot header %}<h2>Weather</h2>{% endcotton:slot %}
View this page as markdown, handy as context for your AI tools. Full index at /llms.txt. Spotted a mistake? Edit this page on GitHub.