Div text blocks in AI layouts: from raw paragraphs to structured SwiftUI content

AI assistants are great at generating text, but paragraphs alone are a poor interface. For iOS apps, the real power comes when those AI responses become…

Specimen tray of staggered book spines symbolizing structured AI text blocks in SwiftUI layouts

AI assistants are great at generating text, but paragraphs alone are a poor interface. For iOS apps, the real power comes when those AI responses become structured SwiftUI content — headings, lists, and callouts that feel native.

This is exactly where div text blocks in generative UI JSON meet Uzori’s SwiftUI interface layer: you let the model emit semantic text regions, then you turn them into real, server‑validated screens without handing over full layout control.

In this guide, we’ll unpack how that works.

What are div text blocks in generative UI JSON?

In most generative UI and server‑driven UI systems, a div text block is the smallest semantic unit for text. It’s not a layout system in itself — it’s a node that carries text and metadata inside a larger container.

Typical properties you’ll see in JSON formats inspired by DivKit or similar frameworks:

  • type: "text" or "div-text" to mark the element
  • text: the actual string or rich text payload
  • font, line_height, text_alignment: basic style hints
  • actions: tap or long‑press behaviors
  • accessibility: label, value, traits

The key architectural idea from DivKit’s docs is:

  • Text blocks are content, not structure.
  • Real layout should come from containers, auto‑layout, and templates — not from spacer hacks or clever paragraph formatting.

That maps neatly onto SwiftUI:

  • Text is your content node
  • VStack, HStack, List, Section, ScrollView, and custom views are your structure

When you generate UI from AI, you want models to describe what the text means, not micromanage where it sits pixel‑by‑pixel.

Why raw AI paragraphs are not enough for native iOS UI

If you simply stream LLM output into a chat bubble, you get:

  • Long paragraphs
  • Mixed headings and body text
  • Inline lists hidden in prose

For goal‑oriented tasks, that’s sub‑optimal.

Research backs this up:

  • A JMIR usability study found a single‑page graphical form scored 76 SUS, versus 67 for multipage and 57 for a conversational form, indicating structured interfaces outperform pure chat for task completion.
  • A 2024 comparative paper reported that conversational UIs feel natural and engaging but cannot replace full GUIs for decision‑making tasks.
  • Stack Overflow’s 2025 survey shows 47.6% of developers prefer lists of recommendations and 40.8% prefer long‑form articles, while only 33.2% prefer chat, signalling that structured content remains the default expectation.

For mobile, the stakes are high:

  • Sensor Tower’s State of Mobile 2025 reports 4.2 trillion hours spent in apps and $150B in consumer spend in a year.
  • Small UX efficiency gains can translate into big commercial impact.

So the goal becomes:

Promote AI paragraphs into native, structured SwiftUI content that drives action, not just reading.

From LLM responses to generative UI JSON

Modern AI UI stacks are converging on a common pattern:

  1. User asks for something (e.g., “Help me choose a roaming plan for a week in Japan”).
  2. The LLM reasoner calls your backend APIs (OpenAPI/REST, sometimes GraphQL) via tools.
  3. Instead of emitting pure text, it returns a structured UI spec — often JSON — composed from an allowlisted component catalog.
  4. The client renders those components into native views.

Frameworks like LangChain’s declarative generative UI, json‑render, OpenUI, assistant‑ui, and Thesys all:

  • Let the model choose components and props
  • Guardrail it via a component catalog
  • Reject arbitrary layout code for safety and predictability

In this world, div text blocks become the way AI says:

  • “This is a heading region.”
  • “This is body copy explaining a decision.”
  • “This is a bullet list of options.”
  • “This is a warning or success callout.”

Uzori adopts the same philosophy but with SwiftUI‑native constraints.

Uzori’s approach: generate native iOS UI from LLM responses

Uzori focuses on one thing:

Turn LLM responses into fully native SwiftUI interfaces, validated server‑side and streamed live into your app.

Instead of a chat box, you get:

  • SwiftUI screens composed from a typed schema
  • A server‑approved catalog of components and layouts
  • Streaming updates as the assistant refines the flow

Core elements:

  • Uzori iOS SDK (SwiftUI): a one‑screen integration that hooks your app into Uzori’s engine
  • AI engine: understands user intent, calls your OpenAPI‑described backend, and emits a SwiftUI screen spec
  • Server validation: checks every generated screen against an allowlisted schema before it hits the device

Where div text blocks come in:

  • The AI emits text regions tagged by role
  • These regions are mapped to your SwiftUI components and design system tokens
  • Layout remains constrained by the schema and your server rules

You get generative UI plus server‑driven safety.

Turning AI-emitted text regions into headings, lists, and callouts

The practical question for iOS teams is:

How do we turn div text blocks from AI into structured SwiftUI content that matches our design system?

Uzori’s answer is a three‑step pattern.

1. Classify text regions by semantic role

Instead of treating every div text block as generic body copy, Uzori encourages a semantic contract:

  • role: "heading" — section titles, step labels
  • role: "subtitle" — short supporting lines under headings
  • role: "body" — main explanatory paragraphs
  • role: "list-item" — bullet or numbered points
  • role: "callout-info", "callout-warning", "callout-success" — highlighted messages

Models are instructed (via system prompts and tool docs) to:

  • Emit multiple text blocks per screen
  • Assign appropriate roles to each region
  • Avoid encoding layout via spacing text like "-----" or manual line breaks as structure

Because div text blocks are small and cheap in token space, this also aligns with newer formats like OpenUI Lang that push for token‑efficient, component‑based specs.

2. Map roles to SwiftUI view patterns

On the device, you never render the raw AI JSON directly. Uzori’s SDK and your view layer do the mapping.

Common mappings:

  • Headings → Text(title).font(.title.bold()) or your design system’s TitleText
  • Subtitles → Text(subtitle).font(.subheadline)
  • Body → Text(body).font(.body).foregroundStyle(.secondary)
  • List items → List or VStack with bullet markers
  • Callouts → custom CalloutView with background, icon, and role‑dependent accent

Because SwiftUI’s Text already supports AttributedString and Markdown, you can:

  • Render inline emphasis (**bold**, _italic_) from AI safely
  • Attach accessibility modifiers (.accessibilityLabel, .accessibilityValue) based on JSON metadata
  • Control truncation, wrapping, and scaling from your own policy

The AI never decides:

  • Exact fonts or sizes beyond semantic hints
  • Padding, margins, or visual density
  • Navigation structure or deep layout trees

Those stay in your schema and templates, not in the model’s hands.

3. Compose structured SwiftUI screens from validated specs

Uzori sits between the AI and the app as the contract enforcer:

  • Models emit JSON that conforms to a SwiftUI‑oriented schema
  • The server validates types, roles, and component usage
  • The SDK streams approved screens as SwiftUI view structs

A typical flow:

  1. User asks for help (e.g., "Find gowns under $500 with long sleeves").
  2. AI calls product APIs and emits a screen spec:
    • Heading: "Gowns under $500 with long sleeves"
    • Body: rationale text explaining filters
    • List: cards with image, title, price
    • Callout: "Tip: Try filtering by fabric for more options"
  3. Server validates:
    • Only approved components used (List, Card, Callout)
    • All text regions have roles
    • No arbitrary layout expressions
  4. SDK renders in SwiftUI using your design system.

Uzori’s own direction explicitly matches this pattern of generative layout with server‑driven guardrails.

Avoiding chat-style UX while staying safe

Many teams want to avoid a generic chat box but remain cautious about AI freedom. Uzori’s design addresses both concerns:

  • You get task‑specific flows (wizards, comparison views, explorers) instead of longchat transcripts.
  • You keep everything native, using SwiftUI and your own component library.
  • You ensure safety via:
    • Typed schemas
    • Allowlisted components
    • Server‑side validation

Compared to pure server‑driven UI (SDUI):

  • Systems like DivKit and Voqal highlight reuse, templates, and backend control.
  • But they can introduce client‑server coupling and schema versioning complexity.

Uzori sits at the intersection:

  • Generative UI for intelligent orchestration
  • Server‑driven safety for predictable structure
  • SwiftUI native focus for platform‑consistent UX

This gives you an AI interface layer beyond chat UI while preserving stability and quality.

Example: converting generative UI JSON to SwiftUI

Let’s sketch a simplified JSON spec with div text blocks:

{
"screen": {
"type": "product-assistant",
"sections": [
{
"type": "intro",
"texts": [
{ "type": "text", "role": "heading", "text": "Your roaming plan" },
{ "type": "text", "role": "body", "text": "Here’s a plan tailored to your week in Japan." }
]
},
{
"type": "details",
"texts": [
{ "type": "text", "role": "list-item", "text": "7 days coverage" },
{ "type": "text", "role": "list-item", "text": "10GB high-speed data" },
{ "type": "text", "role": "list-item", "text": "Includes hotspot tethering" }
],
"callouts": [
{ "type": "text", "role": "callout-info", "text": "You can upgrade to unlimited anytime." }
]
}
]
}
}

In SwiftUI with Uzori:

  • The intro section becomes a VStack with TitleText and BodyText.
  • The details become a List or VStack with list‑item rows.
  • The callout becomes your branded InfoCalloutView.

SwiftUI pseudo‑code:

IntroSectionView(texts: introTexts) {
VStack(alignment: .leading, spacing: 8) {
for text in texts {
switch text.role {
case .heading:
TitleText(text.value)
case .body:
BodyText(text.value)
default:
EmptyView()
}
}
}
}

DetailsSectionView(texts: detailTexts, callouts: calloutTexts) {
VStack(alignment: .leading, spacing: 12) {
VStack(alignment: .leading, spacing: 4) {
ForEach(listItems) { item in
BulletRow(text: item.value)
}
}

ForEach(calloutTexts) { callout in
InfoCalloutView(message: callout.value)
}
}
}

The important part:

  • The AI never chooses VStack vs List directly.
  • It emits roles and content, and your schema determines the container.

Uzori vs DivKit-style approaches

If you’re comparing Uzori vs DivKit and other server-driven UI iOS frameworks, think about:

  • Rendering target
    • DivKit: cross‑platform JSON rendering with its own component system
    • Uzori: SwiftUI‑native rendering, leveraging Apple’s declarative model
  • Intelligence vs structure
    • Traditional SDUI: strong structure, limited intelligence
    • Pure LLM: strong intelligence, weak structure and safety
    • Uzori: generative UI plus server‑driven validation, tuned for iOS
  • Text block semantics
    • DivKit: div-text nodes with styling, actions, accessibility
    • Uzori: AI‑emitted text regions tagged with roles, mapped to SwiftUI and your design system

If you also work with overlay‑heavy media layouts, you may want to read our companion guide on translating image‑centric Div specs into SwiftUI: descriptive anchor text.

How this fits real-world iOS stacks

Uzori is designed for modern iOS engineering teams:

  • Native Swift/SwiftUI apps
  • Backend APIs documented with OpenAPI or similar
  • Product orgs that care about UX polish and architectural cleanliness

You integrate once:

  • Drop in the Uzori SwiftUI SDK as a single screen.
  • Register your backend endpoints as tools with clear contracts.
  • Let the AI compose task‑specific flows using text blocks, lists, and forms.

The server remains the arbiter of:

  • Which components are allowed
  • How text roles map to views
  • Which layouts are valid for which flows

This keeps your AI UI features:

  • Fast to iterate
  • Safe to ship
  • Consistent with the rest of your app

FAQ: div text blocks, SwiftUI, and Uzori

How do div text blocks in generative UI JSON differ from plain text?

Div text blocks carry structure and metadata, not just strings. They include roles, styling hints, actions, and accessibility data, allowing you to map them to specific SwiftUI components instead of generic labels.

Can I generate SwiftUI directly from AI JSON without a framework?

You can hand‑roll a mapper from JSON to SwiftUI, but you’ll quickly need:

  • A typed schema
  • Validation rules
  • Versioning and migration logic

Frameworks like Uzori exist to standardize this AI UI framework for SwiftUI iOS, so you don’t rebuild the safety and streaming pieces yourself.

How does Uzori prevent unsafe or broken layouts from the model?

Uzori uses server‑validated AI‑generated UI streaming:

  • The back end validates every screen against an allowlisted schema.
  • Only approved components and props are rendered.
  • Invalid specs are rejected or corrected before reaching the device.

This keeps your app safe from arbitrary remote layout code.

Can I keep my existing navigation and flows while adding AI UI?

Yes. Uzori is designed as an AI interface layer that doesn’t break existing flows. You integrate it as a single SwiftUI screen, present it where appropriate (e.g., a concierge tab or setup wizard), and keep your existing navigation and screens intact.

Where can I try turning AI-emitted div text blocks into native SwiftUI content?

You can experiment with mapping AI‑generated text regions to headings, lists, and callouts in your own app by integrating the Uzori SDK from uzori.ai.

By treating div text blocks as semantic building blocks — not layout hacks — and layering them into a server‑validated, SwiftUI‑native interface, you can compress weeks of UI iteration into streaming, AI‑driven screens that feel like your app, not just another chatbot.

← All posts