Compose components
Pass content into a component, then forward an event out of one.
Before you start: Reuse a component.
A slot is a place for caller-supplied content. An emitted event is an explicit output; it does not bubble through arbitrary ancestors. Learn these two boundaries separately.
Compose with a slot
Slot renders children supplied to Panel. Those children keep the caller’s lexical data/state scope. A named slot uses Slot name="footer" and Fill slot="footer".
<UI>
<Component name="Panel" props="title">
<Column class="p-4 gap-2 bg-card rounded-xl">
<Text bind-text="props.title" class="font-headline" />
<Slot />
</Column>
</Component>
<Panel title="Reading list">
<Text text="This content belongs to the caller." />
</Panel>
</UI>
Compose with a slot
editable
rReady to explore
Try it: Change only the caller’s text. The panel definition stays reusable.
Forward one event
The wrapper emits saved; the caller listens with on-saved and reads the payload through event.
<UI>
<Component name="SaveButton">
<Button title="Save" on-press="emit saved with {message:'Saved locally'}" />
</Component>
<Column state="{message:'Ready'}" class="p-4 gap-3">
<SaveButton on-saved="set message to event.message" />
<Text bind-text="message" />
</Column>
</UI>
Forward one event
editable
rReady to explore
Try it: Change the emitted message. Press Save and check the readout.
Next: call your app. Reference: definitions and slots, events.