Appearance
Theme Koah ads in SwiftUI with the .koahTheme(_:) modifier.
Theming
To customize the appearance of Koah ads, apply .koahTheme(_:) once at the root of your view tree and every Koah ad below it picks the theme up via SwiftUI's environment:
ContentView()
.koahTheme(
KoahTheme(
colorScheme: .auto,
accentColor: .green
)
)
For the full list of theme properties, see Theme properties in the reference.
Sizing
Koah ads are fully resizable. Bound each axis independently with the width and height parameters (KoahAxisSize): .fixed(_:) forces an exact size, .range(min:max:) bounds while wrapping content, .fill takes the parent's available space, and omitting an axis lets the card wrap its content within whatever space the parent gives it.
Leaving width / height unbounded allows more ad formats, improving fill
rates and revenue.
KoahCard(
adContext: .conversation(question: q, answer: a),
width: .range(max: 360),
cacheKey: "msg-1"
)
The 0.x overrideMaxWidth / overrideMaxHeight initializer is removed in 1.0 β map those values to width: .range(max:) / height: .range(max:); see the migration guide. See Card sizing in the reference for the full table.
Below the minimum the SDK hides the card (zero-size layout) and logs an error
once. Enforcement is bi-directional β if the container later grows to fit,
SwiftUI's next layout pass re-renders the card. .fill is stricter: it needs
a parent that bounds that axis, so using it on a scroll axis β height inside a
ScrollView or List, width inside a horizontal ScrollView β traps at
layout instead of degrading. Reach for .fixed(_:) or .range(min:max:)
there. See Formats for the full sizing model.
Card chrome
KoahCard renders inside the standard chrome (rounded background, 0.5pt border, padding) by default. Pass chrome: .bare to render borderless and embed the ad directly into your own surface like a chat row or list cell:
KoahCard(
adContext: .conversation(question: q, answer: a),
cacheKey: "msg-1",
chrome: .bare
)