Pass content into components using slots
Header, body (default), and actions slots are all provided.
This is the card body content passed via the default slot.
Slots can contain live components! The counter below is fully interactive.
This card contains a nested Counter component:
When header and actions slots aren't provided, they're simply not rendered.
This card only uses the default slot. No header or actions. The component handles missing slots gracefully.
slots(
t"Default content", # positional = default slot
header=t"Header content", # named slot
actions=t"Footer content" # named slot
)
def template(self, assigns, meta):
header = meta.slots.get("header", t"")
body = meta.slots.get("default", t"Fallback")
return t"<div>{header}{body}</div>"
slots() helper to create slot dictmeta.slots['name'] or .get().get() with fallback for optional slots