Skip to main content

Components, props, and slots

Before you start: reuse and compose components.

A template component is a named XML definition with props and one rendered root. It composes existing primitives and other definitions.

<UI>
<Component name="FeatureCard" props="title">
<Column class="p-4 gap-3 bg-card rounded-xl">
<Text bind-text="props.title" class="font-headline" />
<Slot />
</Column>
</Component>
<FeatureCard title="Trip details">
<Text text="Slot content belongs to the caller." />
</FeatureCard>
</UI>

Pass data through props​

Definitions receive explicit props. They do not capture root data. A slot's content retains the caller's data and state scope. Named slots use Slot name="footer" inside the definition and Fill slot="footer" at the invocation.

Use explicit controlled props and change events when composing parts. This makes state ownership visible without an implicit cross-component context mechanism.

Preserve component state​

Stable keys let the runtime preserve compatible instances during data updates and reordering. Changing source through explicit replacement resets the document. show retains an instance while hiding it; if removes it, so reinsertion creates fresh local state.

Start with the library​

Relo UI Components supplies application-owned XML recipes you can copy, style, and edit. Add custom native adapters for capabilities your app already owns. Compose and SwiftUI host the native renderers; they are not additional renderer implementations.