Div images in AI layouts: moving from screenshot grids to native SwiftUI media cards

AI layouts that rely on div images are fine on the web, but on iOS they quickly become a dead end. If you want AI-generated media to feel native, you should…

Macro still life of a worn slide mount with a blank centre, symbolizing a frame awaiting native SwiftUI media.

AI layouts that rely on div images are fine on the web, but on iOS they quickly become a dead end. If you want AI-generated media to feel native, you should render those div-style image blocks as real SwiftUI media cards instead of screenshot grids or HTML blobs.

In this guide, you’ll see how div-based media layouts usually work, why they fall short on iOS, and how Uzori lets you turn LLM output that references div images into tappable, accessible SwiftUI cards streamed directly into your app.

Div images: how AI layouts usually ship media today

Most AI-generated UIs today assume a web-style layout model.

When a model wants to show media, it often describes something like:

  • A div containing an image (img or background image)
  • Overlay text in another div on top of the image
  • Optional footer content (price, badges, buttons) in nested div blocks
  • Click targets bolted on via role="button" and JavaScript handlers

On the web, <div> is a generic container. It has no semantics until you layer CSS and ARIA on top of it.

According to MDN, if a block is meant to be interactive, you should prefer semantic elements like <button> instead of a div with role="button", because ARIA alone does not give you keyboard handling or native button behavior.

In the generative UI world, that often means:

  • AI emits HTML-like structures:
    • div cards around each image
    • div overlays for titles/labels
    • div footers for metadata and CTA
  • Clients render them as:
    • Static screenshot grids
    • Embedded web views
    • Image-only tiles with no real semantics

These div images give you quick visual results, but they don’t translate well into native mobile UX.

From screenshot grids to native media cards

If you’re targeting iOS, screenshot-style grids of AI-generated div images are a compromise.

They tend to be:

  • Static: one image per card, no real-time state or complex interactivity
  • Opaque: layout logic lives in HTML/CSS, not in SwiftUI
  • Hard to test: subtle layout changes require full snapshot review
  • Accessibility-poor: screen readers see images, not structured content

The industry is already moving away from flat, screenshot-style output.

Vendors like Thesys, json-render, and A2UI emphasize:

  • Component catalogs and typed specs
  • Cards, tables, dashboards and forms
  • Progressive, interactive rendering instead of static images

For iOS teams, the question becomes: how do you map these AI-described div layouts to first-class SwiftUI media cards instead of shipping a web workaround?

Why div-style image blocks are a web workaround

div-heavy layouts are a symptom of the web’s flexible but underspecified UI model.

On the web:

  • <div> is the default container for everything
  • Layout, interaction, and semantics are layered later via CSS and JS
  • Image grids are usually composed of nested div blocks with:
    • One div for the image wrapper (div image)
    • One div for overlays (div text)
    • One div for video badges or icons (div video)

This works, but it has tradeoffs when ported directly to mobile:

  • No semantics by default:
    • A div is not a card, not a button, not a list item
    • ARIA roles can help, but only if wired correctly
  • Accessibility costs:
    • You must manually wire keyboard handling
    • You must manually manage focus and activation
  • AI complexity:
    • LLMs generate HTML-like structures, but clients still need to parse, sanitize, and reinterpret them

When you’re building an AI-native iOS app, you don’t want to treat these div images as canonical. They’re just a description of intent: “show a tappable media item with overlays and metadata.”

The right question is: how do we render that intent as SwiftUI media cards instead?

SwiftUI already has what div images are trying to be

SwiftUI gives you typed, composable primitives that are a better fit than generic div blocks.

For AI-generated media cards, your core building blocks are:

  • AsyncImage for remote image loading
  • Image for local or cached assets
  • Button for tappable surfaces (instead of div with role="button")
  • contentShape to control hit-testing regions
  • Grid or LazyVGrid for two-dimensional layouts

Apple’s guidance is clear: if you need an actionable surface, use Button, not a tap gesture. SwiftUI will handle the expected behaviors, including accessibility labels and hints.

Apple also emphasizes that:

  • Any view can be a button label
  • Built-in controls inherit accessibility behaviors
  • AsyncImage supports phased loading and custom placeholders

In other words, SwiftUI already has a native concept of a media card:

  • A tappable container (Button or NavigationLink)
  • With image content (AsyncImage)
  • With overlay and footer text in child views
  • With automatic accessibility and hit targets

Instead of mapping AI-generated div images directly to HTML, you can map them to these SwiftUI primitives.

Generate native iOS UI from LLM responses, not HTML

When you ask an LLM to build an interface, the naive approach is to have it generate HTML (or pseudo-HTML). That’s where div images, div text, and div video blocks usually show up.

A more robust pattern is:

  1. Define a typed SwiftUI component catalog
    • MediaCard with fields: imageURL, title, subtitle, badge, action
    • MediaGrid with a collection of MediaCard items
    • Optional ComparisonView, WizardStep, etc.
  2. Expose that catalog to the LLM
    • Document each component in a schema (JSON/OpenAPI-like)
    • Make clear which combinations are allowed
  3. Let the LLM generate a structured spec
    • Instead of HTML, it returns a tree of components and props
    • For example: MediaGrid(cards: [...])
  4. Render that spec as SwiftUI
    • The client just switches on component types
    • Each type maps directly to your native SwiftUI views

This aligns with how companies like Voqal and A2UI frame generative UI: the LLM produces a structured representation over a fixed, safe component catalog. A dedicated renderer then turns that spec into native UI.

On iOS, that renderer is SwiftUI.

Server-driven UI SwiftUI media cards: why it’s back in favor

Server-driven UI (SDUI) is having a resurgence, especially for highly dynamic surfaces.

Thoughtworks moved SDUI back into its “Trial” ring in April 2026, noting that generic client containers plus server-provided structure can:

  • Shorten time-to-production
  • Avoid repeated app store reviews
  • Reduce client-side duplication and drift

They also warn against “god-protocols”: SDUI should focus on dynamic areas, not replace all UI.

For AI-generated media surfaces (grids of images, video cards, product decks), SDUI is a natural fit:

  • The server (and LLM) decide what cards to show
  • The client renders a small set of known SwiftUI components
  • Changes roll out immediately without an app update

Uzori sits precisely at this intersection of generative UI and SDUI for iOS:

  • The AI composes layouts
  • The server validates them against a schema
  • The client renders SwiftUI media cards in real time

No HTML, no WebView, no screenshot grids.

Uzori: turn LLM div images into SwiftUI media cards

Uzori’s core idea: the AI response is your app’s interface.

Instead of answering with text or HTML, an AI agent responds with generated SwiftUI screens, validated on your server and streamed into your app through the Uzori iOS SDK.

This is how Uzori handles div-style media layouts:

  1. LLM sees div images as intent, not as implementation
    • You prompt the model with your component catalog, not HTML tags
    • When a user asks for “gowns,” the model returns MediaGrid with MediaCard items
  2. Server validates the UI spec
    • A typed schema defines allowed layouts and props
    • Every card is checked for correctness and safety before streaming
  3. Uzori SDK renders native SwiftUI media cards
    • A single SwiftUI screen acts as the host
    • Uzori streams the validated UI spec into that host
    • The host composes cards with AsyncImage, Button, and your design system
  4. Users interact with real, tappable cards
    • Cards navigate, drill down, or call backend APIs
    • No web views, no HTML parsing, no screenshot grids

The result: LLM-driven media surfaces that feel like your app, not like an embedded web page.

Example: convert div on image layouts to SwiftUI cards

For a deeper, pattern-level walkthrough of overlay-heavy media layouts, see our related guide: Div on image layouts: translating overlay-heavy media UI to native SwiftUI.

Here, we’ll focus on a concrete SwiftUI-oriented flow.

What the LLM output might say

Traditional, web-centric LLM output might look like:

{
"type": "grid",
"items": [
{
"type": "div-image-card",
"imageUrl": "https://.../dress-1.jpg",
"title": "Evening gown",
"price": "$240",
"badge": "Most popular",
"action": {
"type": "openProduct",
"id": "dress-1"
}
}
]
}

Instead of trying to render that literally, Uzori treats div-image-card as a semantic hint that maps to your MediaCard component.

What the SwiftUI side sees instead

On the iOS side, you define a typed model:

struct MediaCardSpec: Decodable, Identifiable {
let id: String
let imageURL: URL
let title: String
let subtitle: String?
let badge: String?
let action: CardAction
}

struct MediaGridSpec: Decodable {
let cards: [MediaCardSpec]
}

Uzori’s engine produces a MediaGridSpec that your SDK host view consumes:

struct MediaGridView: View {
let spec: MediaGridSpec

var body: some View {
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) {
ForEach(spec.cards) { card in
Button(action: { handle(card.action) }) {
MediaCardView(card: card)
}
.buttonStyle(.plain)
.contentShape(Rectangle())
}
}
.padding()
}
}

MediaCardView internally uses AsyncImage with placeholders and overlays. The AI never emits HTML; it only emits MediaGridSpec and MediaCardSpec instances.

That’s how you convert div images and div on image patterns into native SwiftUI media cards.

Safety and validation: generative UI, server-driven safety

The latest generative UI stacks treat safety and validation as primary features.

A few data points:

  • Thesys reports that after tightening validation, malformed-output errors dropped from 3% to under 0.3%
  • A2UI emphasizes declarative, pre-approved component catalogs over executable code
  • Voqal frames native generative UI as a typed spec over a fixed catalog

Uzori takes the same stance:

  • Typed schemas:
    • Every SwiftUI component has a schema-backed representation
    • LLMs can only use what’s defined in the catalog
  • Server-side validation:
    • Screens are validated on your server before they’re streamed
    • No arbitrary code ever executes on the client
  • Native rendering:
    • The iOS app only renders known SwiftUI components
    • No untrusted HTML, JS, or remote code paths

This “generative UI, server-driven safety” model lets you iterate quickly without sacrificing control.

Why this matters for accessibility and UX

Translating div images into real SwiftUI components has big accessibility and UX advantages.

Level Access’s 2025–2026 report found:

  • 91% of respondents say accessibility improves UX
  • 90% say it improves customer satisfaction
  • 81% say it improves retention
  • 82% say they’re incorporating AI tools into accessibility strategies

If your AI surfaces are just screenshot grids or HTML in a web view, you’re leaving a lot of that value on the table.

SwiftUI media cards give you:

  • Native focus and activation behavior
  • VoiceOver labels and hints via standard modifiers
  • Larger, consistent hit targets with contentShape
  • Grid layouts that adapt to device size and orientation

And because Uzori’s AI works over your component catalog, you can bake accessibility requirements directly into each component.

One screen to integrate, infinite media flows to explore

The Stack Overflow 2025 survey reports that 84% of respondents are using or planning to use AI tools, and 51% of professional developers use them daily. But turning AI output into real, shippable UI is often the bottleneck.

Uzori’s iOS SDK is designed to reduce that cost:

  • Single-screen integration:
    • Drop in a SwiftUI host view
    • Wire it to your backend and Uzori’s engine
  • Existing APIs, new flows:
    • Describe your backend with OpenAPI
    • Let AI orchestrate product explorers, galleries, and comparison views
  • Streaming updates:
    • New media cards and layouts stream into the host
    • Users see adaptive UI in real time

You keep your architecture and design system. Uzori sits on top as an AI interface layer that turns LLM intent—including legacy notions like div images—into native SwiftUI.

If you want to experiment with this pattern in your own app, you can explore the SDK and examples at uzori.ai.

FAQ: div images, SwiftUI media cards, and Uzori

How do I convert HTML div layouts to SwiftUI in practice?

You don’t need to parse HTML literally. Instead:

  1. Identify the patterns in your div layouts (e.g., media card, hero banner, list item)
  2. Define SwiftUI components that cover those patterns
  3. Build a typed schema representing those components
  4. Teach your LLM to output that schema instead of HTML
  5. Use a server-driven renderer (like Uzori) to map the schema to SwiftUI views

The “conversion” is from pattern to component, not from HTML to Swift.

Can Uzori render div images as native SwiftUI components directly?

Uzori doesn’t render raw div blocks. Instead, it:

  • Interprets div-style media patterns as semantic cards
  • Maps those patterns to your SwiftUI component catalog
  • Streams the resulting SwiftUI screen spec into your app

So if your LLM currently thinks in terms of div images, the transition is to teach it to think in terms of MediaCard and MediaGrid instead.

Is this approach compatible with existing server-driven UI iOS frameworks?

Yes.

Uzori effectively acts as a specialized SDUI layer focused on AI-generated flows and SwiftUI. If you already use SDUI:

  • You can integrate Uzori in a specific surface (e.g., AI concierge screen)
  • You can reuse your existing infrastructure for authentication, feature flags, and logging
  • You can gradually migrate AI-driven surfaces from HTML/web to typed SwiftUI specs

What about performance and latency when streaming SwiftUI screens?

Because Uzori sends structured specs, not full HTML or screenshots, payloads remain small.

Combined with streaming, this allows:

  • Early rendering of partial results
  • Incremental loading of media cards
  • Consistent performance across different AI flows

Native SwiftUI rendering also avoids the overhead of WebViews and cross-platform layers.

How do ethical AI and privacy considerations fit in?

Ethical AI on mobile includes:

  • Clear boundaries between AI-generated UI and sensitive user data
  • No arbitrary code execution from untrusted sources
  • Transparent control over what data flows into LLM prompts

Uzori’s model—typed specs, server validation, and native rendering—helps enforce those boundaries by design. You decide which components exist, what data they expose, and how they behave.

← All posts