Appearance
Customize your theme once to apply automatically across every Koah ad format.
Theming
Set the theme object on init for the first render, or update it at runtime to re-theme on the fly. Both accept the same theme tokens.
<script>
window.koah_init = window.koah_init || {}
window.koah_init.theme = {
colorScheme: 'dark',
presentationMode: 'card',
accentColor: '#3b82f6',
}
</script>
<script async src="https://app.koah.ai/js?token=<YOUR_PUBLISHER_ID>"></script>
For the full token list (color scheme, accent, font, width, chrome), see Theme tokens in the reference.
Sizing
Koah ads are fully resizable. Control size using the dimensions argument (maxWidth / maxHeight, in CSS pixels) as needed—each axis is independent, and Koah serves only the formats that fit.
Omitting dimensions allows more ad formats, improving fill rates and
revenue.
window.koah.requestAd({
target: document.getElementById('ad-slot'),
context: { type: 'conversation', question, answer },
dimensions: { maxWidth: 480, maxHeight: 300 },
})
See Format bounds for the per-variant table and Ad formats for the shared sizing model.
Sizing for mobile and desktop
Set the maximum size of the slot in CSS. Then read that size and send it with the request.
Give the slot a max-width, a max-height, and overflow: hidden. The ad then stays inside the space you give it. Use a media query or a container query to make the slot smaller on a narrow screen. Write both maximums in pixels, because a percentage gives no usable number in JavaScript.
#ad-slot {
max-width: 768px;
max-height: 550px;
overflow: hidden;
}
/* Give mobile web less room. */
@media (max-width: 640px) {
#ad-slot {
max-width: 360px;
max-height: 400px;
}
}
Make the slot as large as you're comfortable with. We'll still serve ads smaller than the slot, but a bigger slot gives us the option to serve larger, higher-eCPM formats when they're available. We recommend at least a max height of 400px if your layout permits it. See Sizing & dimensions.
Send the true size. A slot narrower than 240 px, or shorter than 72 px, cannot
show an ad: requestAd resolves with { filled: false } and calls
onNoFill. Do not send a larger size than the slot has, or overflow: hidden
clips the ad.