Skip to content
kitn AI/UI

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

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 with media-type so the browser decodes correctly.
  • bytes — assign it in JavaScript (Uint8Array); media-type is recommended but not required when the format is detectable.
  • media-type defaults to image/png. Override for SVG (image/svg+xml), JPEG, or any other MIME type.
  • alt defaults to an empty string — always provide meaningful alt text.

A base64-encoded SVG with explicit media-type and descriptive alt text.

A different base64 SVG — swap base64 and media-type for each image you display.

Pairs the image with a specific alt string so screen readers announce it correctly.

PropertyTypeDefaultNotes
base64 Base64-encoded image data (pair with `media-type`).
bytes Raw image bytes (set as a JS property).
alt '' Alt text.
mediaType MIME type (default `image/png`).

This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.

Image