Skip to content
Flow-UILive
On this page

Bottom sheets described by the backend

`open_bottom_sheet` carries a sheet envelope: detents, header, sections, footer. The client presents native SwiftUI, not a web modal.

Ayush MishraPublished 6 min read

open_bottom_sheet carries a sheet envelope: detents, header, sections, footer. The client presents native SwiftUI, not a web modal. The same registry that rendered the page renders the sheet. The same widgets, including host types and accordion children, work there without a second catalogue.

This is not navigation to a new pageID. It is presentation on the current page. Pushing another store is a host deeplink, as deep linking through host handlers described. Reloading this document is refresh_page. Mutating this document is api. A sheet is extra widgets in a platform detent.

The field list is Bottom sheets. Server driven navigation with actions named the built-in. This article is SheetModel, FlowSheetView, and the host fetch case the built-in refuses to do.

SheetModel is a page-shaped envelope with different chrome#

SheetModel has id, optional header and footer as PageBar, sections as a lossy list of SectionModel, and config as SheetConfig. It is Identifiable because SwiftUI .sheet(item:) needs identity.

If JSON omits id, decode assigns sheet. plus an eight-character UUID prefix. That fallback is presentation identity, not list identity. Two inline sheets decoded from the same action key sit at the same coding path. A shared positional id would stop SwiftUI from swapping one for the other. Do not copy this UUID pattern onto widgets. Widgets use prefix@codingPath as stable widget identities explained.

FlowSheetView.swiftswift
public struct FlowSheetView: View {
    public init(_ model: SheetModel) { self.model = model }
 
    public var body: some View {
        VStack(spacing: 0) {
            if let header = model.header { bar(header) }
            ScrollView {
                LazyVStack(spacing: 0, pinnedViews: [.sectionHeaders]) {
                    ForEach(model.sections) { section in
                        SectionRenderer(section)
                    }
                }
            }
            if let footer = model.footer { bar(footer) }
        }
    }
}

Header and footer stay fixed. Sections scroll. WidgetRowView renders each widget in those bars. Detents, grabber, corner radius, and interactive dismiss come from config.

swift
context.presenter?.present(sheet: sheet)

FlowPageView already presents presenter.activeSheet with FlowSheetView, copying registry, state store, dispatcher, and relay into the sheet environment. You can present FlowSheetView from host UI as well. The presenting view’s Flow-UI environment carries in.

Config the backend actually owns#

SheetConfig keys:

  • detents: JSON array of "medium", "large", a number fraction such as 0.4, or a string that parses as Double. Empty or missing becomes [.medium, .large]. Unknown values are ignored. If everything is unknown, the same default pair applies.
  • grabber (property showsGrabber): default true. Maps to presentationDragIndicator.
  • dismissible (isDismissible): default true. False sets interactiveDismissDisabled. Provide a dismiss action in the footer so the user can leave.
  • corner_radius: optional double for top rounding.

This is native presentation. It is not a WKWebView stuffed into a platform sheet. VoiceOver, grabber, and detents are UIKit/SwiftUI presentation. That is the same native argument as SDUI on iOS: native SwiftUI, not WebViews.

open_bottom_sheet decode path#

OpenBottomSheetActionHandler requires action.raw["sheet"] and a registry on context.pageStore. It builds FlowDecoder.make(widgetDecoding:diagnostics:) and decodes SheetModel. On success it present(sheet:). On failure it returns false (not claimed), which is different from toast’s “claim even if malformed.” A bad sheet payload will log as unhandled unless you override the handler.

Widgets inside the sheet decode through that same registry. Starter types from starter widgets as worked examples and your overrides both apply. Last registration still wins.

When the sheet JSON is not inline#

The built-in comment is explicit: sheets that need a network round trip are a host concern. Register your own type (open_remote_sheet, name it), fetch with the same PageLoader or another client, decode SheetResponse or SheetModel, then presenter.present or redispatch an open_bottom_sheet with the inline payload.

Flow-UI will not fetch the sheet for you. It does not network. Putting a URL on open_bottom_sheet and hoping the package calls it will fail decode or present nothing.

Keep remote sheet fetches cancellable. If the page dismissed, do not present. ActionDispatcher.cancelInFlight() helps when the handler awaits.

dismiss inside a sheet#

{ "type": "dismiss" } closes the active sheet when one is up. Footer Done buttons need zero extra host code for the simple case. If the host set onDismiss, that closure wins over sheet-clearing. Wire onDismiss only when you need custom teardown. For the default, leave it nil so sheets close and root pages set dismissRequested.

What belongs in a sheet versus a page#

Use a sheet for confirmation, filters, a short form, or extra detail that should not replace the page underneath. Use a page when the user should be able to deep link, paginate, or treat the surface as a location in your router.

Do not paginate inside a sheet through PageStore.loadNextPage. Pagination is a page store concern tied to the page envelope. A sheet can contain many sections, but it is one decoded SheetModel. If the catalogue is long, push a host page.

Do not put the only checkout CTA exclusively in a sheet type last month’s binary cannot decode. Unknown widgets inside a sheet follow the same policy as the page. An unknown child skips. The sheet chrome still appears.

Backend habits#

Send a stable id when the same sheet can replace itself (filter sheet that updates). Send detents the product actually wants; do not rely on the default if design specified a fraction.

Send dismissible: false only with a visible dismiss control. Trapping users in a sheet is a platform anti-pattern and a VoiceOver problem.

Send real widget ids for steppers in the sheet if you also mutate them. Sheet widgets still participate in ForEach. The page-level deduplicator does not run on SheetModel the way it does on PageModel decode (sheet sections still decode widgets with positional fallbacks per AnyWidget). Prefer explicit ids.

Keep the inline payload small. A sheet that embeds three pages of widgets should have been a pushed page.

Environment that carries into the sheet#

FlowPageView copies flowRegistry, flowStateStore, flowDispatcher, and flowActionRelay onto FlowSheetView. Theme comes from the environment as well. That is why an override of image_text_card applies inside the sheet without a second register call, and why a dismiss action in a footer button_row reaches the same presenter that opened the sheet.

The sheet uses the page’s WidgetStateStore. Expansion flags and stepper counts in the sheet share that store with the page underneath, keyed by widget id. If a sheet stepper reuses a page-level id, they fight. Send distinct ids in the sheet payload.

If you present FlowSheetView yourself, copy the same environment values. A sheet presented without a registry renders nested children as unknown. A sheet presented without a relay makes every tap inert, which looks like a “broken JSON” bug and is actually a missing pipe.

Detents are Set<PresentationDetent>. Duplicate "medium" in JSON is still one detent. Mix "medium" and 0.4 if the product wants both. Empty declared lists fall back to medium and large. That fallback is how an old binary survives a future detent name it does not understand: unknown values are ignored, and if the set would be empty the defaults return.

Where this sits#

Bottom sheets API is the contract. Server driven navigation with actions is the handler chain. Deep linking through host handlers is what you do instead of pretending a sheet is a router. Native presentation, native widgets, host fetch when the JSON cannot be inline.

The Flow-UI mark: two nodes joined through a filled centre

Inline SheetModel, native FlowSheetView, host fetch when you must. Not a web modal.

More on the blog.

Read the source

Flow-UI is MIT licensed. The schema, renderer and starter widgets live on GitHub.

GitHub

Get started with Flow-UI

Install the Swift package, register a widget, and render a page from JSON.

Get started