ui.image · parts: Image, Picture, Source · elements: <img>, <picture>, <source>
Image renders img, picture, and source. Alt is required; pass an empty string for decorative images.
altis required (usealt=""for decorative images).- Art direction:
PicturewithSourcechildren and anImagefallback.
Image renders an img element; alt is always emitted.
| Canonical (templ, Jinja2, MiniJinja) | React / Solid | HTML (Svelte, Vue, WC) | Type | Default | Kind | Description |
|---|---|---|---|---|---|---|
Src |
src |
src |
string |
— | passthrough attr | |
Alt |
alt |
alt |
string (required) |
— | prop | alternative text; empty string for decorative images |
SrcSet |
srcSet |
srcset |
string |
— | passthrough attr | |
Sizes |
sizes |
sizes |
string |
— | passthrough attr | |
Width |
width |
width |
string |
— | passthrough attr | |
Height |
height |
height |
string |
— | passthrough attr | |
Loading |
loading |
loading |
string |
— | passthrough attr | |
Decoding |
decoding |
decoding |
string |
— | passthrough attr |
Also accepts: class (className in React), extra attributes (rest props in UI frameworks, Attrs in templ/Jinja2/MiniJinja, attrs in Twig/Latte; caller wins).
No variants: the primitive ships no visual classes; style it with token classes via class.
Void / self-contained element: children are not accepted.
- No ARIA attributes are rendered by the primitive; rely on native semantics. Pass extra
aria-*through attrs.
Compose the part's classes without rendering it (custom root element, no asChild outside React):
| Runtime | Helper |
|---|---|
| React / Solid / Vue / Svelte / WC | imageClasses({ ... }) from image/image.shared.ts |
| templ | image.ImageClasses(image.ImageProps{...}) |
| Twig | ui8kit_classes('imageClasses', { class: '…' }) |
| Latte | \UI8Kit\Latte\Classes::imageClasses(['class' => '…']) |
| Jinja2 | image_classes(p) |
| MiniJinja | image_classes(p) (registered by ui8kit_minijinja::register) |
Canonical renderer output (children = Content); all 10 runtimes are parity-tested to produce this DOM.
| State | Props | HTML |
|---|---|---|
| defaults | — | <img alt=""> |
| img | {"Src":"/a.png","Alt":"A cat","Width":"64","Height":"64","Loading":"lazy","Decoding":"async"} |
<img src="/a.png" alt="A cat" width="64" height="64" loading="lazy" decoding="async"> |
| decorative | {"Src":"/b.png","Alt":""} |
<img src="/b.png" alt=""> |
| source | {"SrcSet":"/a.webp","Sizes":"100vw"} |
<img alt="" srcset="/a.webp" sizes="100vw"> |
Fixture img ({"Src":"/a.png","Alt":"A cat","Width":"64","Height":"64","Loading":"lazy","Decoding":"async"}) — every snippet renders:
<img src="/a.png" alt="A cat" width="64" height="64" loading="lazy" decoding="async">React (runtime notes)
import { Image } from "./ui/image/image";
<Image alt="A cat" src="/a.png" width="64" height="64" loading="lazy" decoding="async" />Vue 3 (runtime notes)
<script setup lang="ts">
import Image from "./ui/image/Image.vue";
</script>
<template>
<Image alt="A cat" src="/a.png" width="64" height="64" loading="lazy" decoding="async" />
</template>Svelte 5 (runtime notes)
<script lang="ts">
import Image from "./ui/image/Image.svelte";
</script>
<Image alt="A cat" src="/a.png" width="64" height="64" loading="lazy" decoding="async" />SolidJS (runtime notes)
import { Image } from "./ui/image/image.solid";
<Image alt="A cat" src="/a.png" width="64" height="64" loading="lazy" decoding="async" />Web Components (runtime notes)
import { renderImage } from "./ui/image/image.wc";
document.body.append(renderImage({ alt: "A cat", src: "/a.png", width: "64", height: "64", loading: "lazy", decoding: "async" }));Go templ (runtime notes)
import "github.com/ui8kit/codegen/generated/templ/ui/image"
@image.Image(image.ImageProps{Src: "/a.png", Alt: "A cat", Width: "64", Height: "64", Loading: "lazy", Decoding: "async"})Twig (runtime notes)
{% include 'image/Image.html.twig' with { src: '/a.png', alt: 'A cat', width: '64', height: '64', loading: 'lazy', decoding: 'async' } only %}Latte (runtime notes)
{include 'image/Image.latte', src: '/a.png', alt: 'A cat', width: '64', height: '64', loading: 'lazy', decoding: 'async'}Jinja2 (runtime notes)
{% with p = {'Src': '/a.png', 'Alt': 'A cat', 'Width': '64', 'Height': '64', 'Loading': 'lazy', 'Decoding': 'async'} %}{% include 'ui/image/image.html.j2' %}{% endwith %}MiniJinja (Rust) (runtime notes)
{% import 'ui8kit.html' as ui %}
{{ ui.image({'Src': '/a.png', 'Alt': 'A cat', 'Width': '64', 'Height': '64', 'Loading': 'lazy', 'Decoding': 'async'}) }}Picture wraps Source candidates and a fallback Image.
No typed props (only class / attrs / children).
Also accepts: class (className in React), extra attributes (rest props in UI frameworks, Attrs in templ/Jinja2/MiniJinja, attrs in Twig/Latte; caller wins), children.
No variants: the primitive ships no visual classes; style it with token classes via class.
Accepts children (default slot / children / { children... } / trusted HTML string in Twig, Latte, Jinja2, MiniJinja — see runtimes). Void tags selected via tag render no children.
- No ARIA attributes are rendered by the primitive; rely on native semantics. Pass extra
aria-*through attrs.
Compose the part's classes without rendering it (custom root element, no asChild outside React):
| Runtime | Helper |
|---|---|
| React / Solid / Vue / Svelte / WC | pictureClasses({ ... }) from image/image.shared.ts |
| templ | image.PictureClasses(image.PictureProps{...}) |
| Twig | ui8kit_classes('pictureClasses', { class: '…' }) |
| Latte | \UI8Kit\Latte\Classes::pictureClasses(['class' => '…']) |
| Jinja2 | picture_classes(p) |
| MiniJinja | picture_classes(p) (registered by ui8kit_minijinja::register) |
Canonical renderer output (children = Content); all 10 runtimes are parity-tested to produce this DOM.
| State | Props | HTML |
|---|---|---|
| defaults | — | <picture>Content</picture> |
Fixture defaults ({}) — every snippet renders:
<picture>Content</picture>React (runtime notes)
import { Picture } from "./ui/image/image";
<Picture>Content</Picture>Vue 3 (runtime notes)
<script setup lang="ts">
import Picture from "./ui/image/Picture.vue";
</script>
<template>
<Picture>Content</Picture>
</template>Svelte 5 (runtime notes)
<script lang="ts">
import Picture from "./ui/image/Picture.svelte";
</script>
<Picture>Content</Picture>SolidJS (runtime notes)
import { Picture } from "./ui/image/image.solid";
<Picture>Content</Picture>Web Components (runtime notes)
import { renderPicture } from "./ui/image/image.wc";
document.body.append(renderPicture({}, "Content"));Go templ (runtime notes)
import "github.com/ui8kit/codegen/generated/templ/ui/image"
@image.Picture(image.PictureProps{}) {
Content
}Twig (runtime notes)
{% include 'image/Picture.html.twig' with { children: 'Content' } only %}Latte (runtime notes)
{include 'image/Picture.latte', children: 'Content'}Jinja2 (runtime notes)
{% with p = {}, children = 'Content' %}{% include 'ui/image/picture.html.j2' %}{% endwith %}MiniJinja (Rust) (runtime notes)
{% import 'ui8kit.html' as ui %}
{{ ui.picture({}, children='Content') }}Source renders a source candidate inside picture.
| Canonical (templ, Jinja2, MiniJinja) | React / Solid | HTML (Svelte, Vue, WC) | Type | Default | Kind | Description |
|---|---|---|---|---|---|---|
SrcSet |
srcSet |
srcset |
string |
— | passthrough attr | |
Media |
media |
media |
string |
— | passthrough attr | |
Type |
type |
type |
string |
— | passthrough attr | |
Sizes |
sizes |
sizes |
string |
— | passthrough attr |
Also accepts: extra attributes (rest props in UI frameworks, Attrs in templ/Jinja2/MiniJinja, attrs in Twig/Latte; caller wins).
No variants: the primitive ships no visual classes; style it with token classes via class.
Void / self-contained element: children are not accepted.
- No ARIA attributes are rendered by the primitive; rely on native semantics. Pass extra
aria-*through attrs.
Canonical renderer output (children = Content); all 10 runtimes are parity-tested to produce this DOM.
| State | Props | HTML |
|---|---|---|
| defaults | — | <source> |
| source | {"SrcSet":"/a.webp","Type":"image/webp","Media":"(min-width: 40rem)","Sizes":"100vw"} |
<source srcset="/a.webp" media="(min-width: 40rem)" type="image/webp" sizes="100vw"> |
Fixture source ({"SrcSet":"/a.webp","Type":"image/webp","Media":"(min-width: 40rem)","Sizes":"100vw"}) — every snippet renders:
<source srcset="/a.webp" media="(min-width: 40rem)" type="image/webp" sizes="100vw">React (runtime notes)
import { Source } from "./ui/image/image";
<Source srcSet="/a.webp" type="image/webp" media="(min-width: 40rem)" sizes="100vw" />Vue 3 (runtime notes)
<script setup lang="ts">
import Source from "./ui/image/Source.vue";
</script>
<template>
<Source srcset="/a.webp" type="image/webp" media="(min-width: 40rem)" sizes="100vw" />
</template>Svelte 5 (runtime notes)
<script lang="ts">
import Source from "./ui/image/Source.svelte";
</script>
<Source srcset="/a.webp" type="image/webp" media="(min-width: 40rem)" sizes="100vw" />SolidJS (runtime notes)
import { Source } from "./ui/image/image.solid";
<Source srcset="/a.webp" type="image/webp" media="(min-width: 40rem)" sizes="100vw" />Web Components (runtime notes)
import { renderSource } from "./ui/image/image.wc";
document.body.append(renderSource({ srcset: "/a.webp", type: "image/webp", media: "(min-width: 40rem)", sizes: "100vw" }));Go templ (runtime notes)
import "github.com/ui8kit/codegen/generated/templ/ui/image"
@image.Source(image.SourceProps{SrcSet: "/a.webp", Type: "image/webp", Media: "(min-width: 40rem)", Sizes: "100vw"})Twig (runtime notes)
{% include 'image/Source.html.twig' with { srcSet: '/a.webp', type: 'image/webp', media: '(min-width: 40rem)', sizes: '100vw' } only %}Latte (runtime notes)
{include 'image/Source.latte', srcSet: '/a.webp', type: 'image/webp', media: '(min-width: 40rem)', sizes: '100vw'}Jinja2 (runtime notes)
{% with p = {'SrcSet': '/a.webp', 'Type': 'image/webp', 'Media': '(min-width: 40rem)', 'Sizes': '100vw'} %}{% include 'ui/image/source.html.j2' %}{% endwith %}MiniJinja (Rust) (runtime notes)
{% import 'ui8kit.html' as ui %}
{{ ui.source({'SrcSet': '/a.webp', 'Type': 'image/webp', 'Media': '(min-width: 40rem)', 'Sizes': '100vw'}) }}