Image
kai-image
Display a model-generated or in-memory image directly from a base64 string or raw byte array — no CDN upload, no hosted URL needed.
- Shadow DOM
- Base64 or Uint8Array input
- Skeleton while resolving
- SVG / PNG / JPEG / any MIME type
- Alt text for accessibility
Preview
Section titled “Preview”Assign either base64 (paired with media-type) or bytes as a property:
<kai-image id="img" media-type="image/png" alt="A generated chart"></kai-image>
<script type="module"> import '@kitn.ai/ui/elements';
const img = document.getElementById('img');
// base64 string: img.base64 = '<...base64 encoded image data...>';
// or raw bytes: // img.bytes = new Uint8Array([...]);</script>base64— scalar attribute or property; pair withmedia-typeso the browser decodes correctly.bytes— assign it in JavaScript (Uint8Array);media-typeis recommended but not required when the format is detectable.media-typedefaults toimage/png. Override for SVG (image/svg+xml), JPEG, or any other MIME type.altdefaults to an empty string — always provide meaningful alt text.
Examples
Section titled “Examples”Purple Star
Section titled “Purple Star”A base64-encoded SVG with explicit media-type and descriptive alt text.
Teal Circle
Section titled “Teal Circle”A different base64 SVG — swap base64 and media-type for each image you display.
With Descriptive Alt Text
Section titled “With Descriptive Alt Text”Pairs the image with a specific alt string so screen readers announce it correctly.
| Property | Type | Default | Notes |
|---|---|---|---|
| base64 | string | — | Base64-encoded image data (pair with `media-type`). |
| bytes | Uint8Array<ArrayBufferLike> | — | Raw image bytes (set as a JS property). |
| alt | string | '' | Alt text. |
| mediaType | string | — | MIME type (default `image/png`). |
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.
Image