Embed
kai-embed
Drop a YouTube, Vimeo, or custom player into any generative-UI response — renders a poster and play button first; no provider iframe, scripts, or cookies load until the user clicks play.
- Shadow DOM
- YouTube · Vimeo · generic
- Privacy-first lazy facade
- Allowlist required for generic origins
- Always-present "Open on provider" fallback
Preview
Section titled “Preview”Set data in JavaScript (it’s an object, not an attribute) on the element:
<kai-embed id="em"></kai-embed><script type="module"> import '@kitn.ai/ui/elements'; const em = document.getElementById('em'); em.data = { provider: 'youtube', id: 'dQw4w9WgXcQ', title: 'Product intro' };</script>provider— required;'youtube','vimeo', or'generic'. YouTube usesyoutube-nocookie.com; Vimeo appendsdnt=1. Neither loads provider JS until play.genericembeds are blocked by default — callconfigureEmbedAllowlist(['https://your-player.example.com'])before setting data. Any unlisted origin is rejected.- Vimeo has no static thumbnail URL — supply a
posterURL or the facade renders without an image. - “Open on provider” is always visible; on click it fires
kai-cardwith{ kind: 'open', target: 'tab' }— handle it to open the URL yourself.
Examples
Section titled “Examples”YouTube (Lazy)
Section titled “YouTube (Lazy)”Generic Player
Section titled “Generic Player”An allowlisted https URL framed as a generic embed.
Custom Aspect Ratio (9:16)
Section titled “Custom Aspect Ratio (9:16)”Set aspectRatio to '9:16' for a vertical short.
Blocked-Embed Fallback
Section titled “Blocked-Embed Fallback”Some providers block framing via X-Frame-Options or CSP. The “Open on provider” affordance is always visible, so a blocked embed is never a dead end.
| Property | Type | Default | Notes |
|---|---|---|---|
| cardId | string | — | Stable card id correlating every emitted event. Set as an attribute or property. |
| data | | — | The embed payload (provider + id/url + options). Set as a JS **property** (object). |
Composed from
Section titled “Composed from”This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.
Embed