Teach Flow-UI a new server driven UI component in three steps, entirely from your own app: model the payload, write the SwiftUI view, register it.
Adding a widget never touches framework code. You agree a type string and a data shape with your backend team, then write three things in your app: a payload model, a view, and one registration call.
import FlowCorestruct OrderCardContent: WidgetContent, Hashable { static let widgetType = "order_card" let orderNumber: TextData let status: TagData? let items: [TextData] let total: TextData? private enum CodingKeys: String, CodingKey { case orderNumber = "order_number" case status, items, total }}
Reuse the FlowCore atoms wherever they fit. TextData, TagData and friends buy you fonts, colors, dark mode and theming with no extra work.
import SwiftUIimport FlowRenderstruct OrderCardWidget: WidgetView { let content: OrderCardContent let context: WidgetContext var body: some View { VStack(alignment: .leading, spacing: 10) { HStack { FlowText(content.orderNumber) if let status = content.status { FlowTag(status) } } ForEach(Array(content.items.enumerated()), id: \.offset) { _, item in FlowText(item) } if let total = content.total { Divider() FlowText(total) } } }}
Do not apply margins, padding, backgrounds or corners yourself. The backend sends them in layout and the renderer applies them around your view. Your view owns only what is inside.
Done. The widget now works everywhere: vertical sections, carousels, grids, headers, footers, bottom sheets, and nested inside containers like the accordion. Envelope actions, layout chrome, diagnostics and the debug console all apply automatically.