ui.box · parts: Box · elements: <div>
Box is the polymorphic structural primitive. tag accepts HTML5 structural
elements only (sections, lists, tables, fieldset); anything else falls back to div.
Forms use the Form primitive (Box no longer accepts form).
- Prefer semantic tags (
section,nav,ul, …) overdivwhen the content has meaning.
Box renders the requested structural HTML element (default div).
| Canonical (templ, Jinja2, MiniJinja) | React / Solid | HTML (Svelte, Vue, WC) | Type | Default | Kind | Description |
|---|---|---|---|---|---|---|
Tag |
tag |
tag |
"div" | "section" | "article" | "aside" | "header" | "footer" | "main" | "nav" | "figure" | "search" | "ul" | "ol" | "li" | "dl" | "dt" | "dd" | "fieldset" | "table" | "thead" | "tbody" | "tfoot" | "tr" | "th" | "td" | "caption" | "colgroup" | "col" |
— | prop | HTML5 structural tag (default div) |
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 | boxClasses({ ... }) from box/box.shared.ts |
| templ | box.BoxClasses(box.BoxProps{...}) |
| Twig | ui8kit_classes('boxClasses', { class: '…' }) |
| Latte | \UI8Kit\Latte\Classes::boxClasses(['class' => '…']) |
| Jinja2 | box_classes(p) |
| MiniJinja | box_classes(p) (registered by ui8kit_minijinja::register) |
React additionally supports asChild (merges props onto the single child via Slot).
Canonical renderer output (children = Content); all 10 runtimes are parity-tested to produce this DOM.
| State | Props | HTML |
|---|---|---|
| defaults | — | <div>Content</div> |
| section | {"Tag":"section","Class":"p-4 bg-card text-card-foreground"} |
<section class="p-4 bg-card text-card-foreground">Content</section> |
| table | {"Tag":"table"} |
<table>Content</table> |
| form | {"Tag":"form"} |
<div>Content</div> |
| li | {"Tag":"li","Class":"text-muted-foreground"} |
<li class="text-muted-foreground">Content</li> |
| rejected | {"Tag":"stack"} |
<div>Content</div> |
| Tag=div | {"Tag":"div"} |
<div>Content</div> |
| Tag=section | {"Tag":"section"} |
<section>Content</section> |
| Tag=article | {"Tag":"article"} |
<article>Content</article> |
| Tag=aside | {"Tag":"aside"} |
<aside>Content</aside> |
| Tag=header | {"Tag":"header"} |
<header>Content</header> |
| Tag=footer | {"Tag":"footer"} |
<footer>Content</footer> |
| Tag=main | {"Tag":"main"} |
<main>Content</main> |
| Tag=nav | {"Tag":"nav"} |
<nav>Content</nav> |
| Tag=figure | {"Tag":"figure"} |
<figure>Content</figure> |
| Tag=search | {"Tag":"search"} |
<search>Content</search> |
| Tag=ul | {"Tag":"ul"} |
<ul>Content</ul> |
| Tag=ol | {"Tag":"ol"} |
<ol>Content</ol> |
| Tag=li | {"Tag":"li"} |
<li>Content</li> |
| Tag=dl | {"Tag":"dl"} |
<dl>Content</dl> |
| Tag=dt | {"Tag":"dt"} |
<dt>Content</dt> |
| Tag=dd | {"Tag":"dd"} |
<dd>Content</dd> |
| Tag=fieldset | {"Tag":"fieldset"} |
<fieldset>Content</fieldset> |
| Tag=table | {"Tag":"table"} |
<table>Content</table> |
| Tag=thead | {"Tag":"thead"} |
<thead>Content</thead> |
| Tag=tbody | {"Tag":"tbody"} |
<tbody>Content</tbody> |
| Tag=tfoot | {"Tag":"tfoot"} |
<tfoot>Content</tfoot> |
| Tag=tr | {"Tag":"tr"} |
<tr>Content</tr> |
| Tag=th | {"Tag":"th"} |
<th>Content</th> |
| Tag=td | {"Tag":"td"} |
<td>Content</td> |
| Tag=caption | {"Tag":"caption"} |
<caption>Content</caption> |
| Tag=colgroup | {"Tag":"colgroup"} |
<colgroup>Content</colgroup> |
| Tag=col | {"Tag":"col"} |
<col> |
Fixture section ({"Tag":"section","Class":"p-4 bg-card text-card-foreground"}) — every snippet renders:
<section class="p-4 bg-card text-card-foreground">Content</section>React (runtime notes)
import { Box } from "./ui/box/box";
<Box tag="section" className="p-4 bg-card text-card-foreground">Content</Box>Vue 3 (runtime notes)
<script setup lang="ts">
import Box from "./ui/box/Box.vue";
</script>
<template>
<Box tag="section" class="p-4 bg-card text-card-foreground">Content</Box>
</template>Svelte 5 (runtime notes)
<script lang="ts">
import Box from "./ui/box/Box.svelte";
</script>
<Box tag="section" class="p-4 bg-card text-card-foreground">Content</Box>SolidJS (runtime notes)
import { Box } from "./ui/box/box.solid";
<Box tag="section" class="p-4 bg-card text-card-foreground">Content</Box>Web Components (runtime notes)
import { renderBox } from "./ui/box/box.wc";
document.body.append(renderBox({ tag: "section", class: "p-4 bg-card text-card-foreground" }, "Content"));Go templ (runtime notes)
import "github.com/ui8kit/codegen/generated/templ/ui/box"
@box.Box(box.BoxProps{Tag: "section", Class: "p-4 bg-card text-card-foreground"}) {
Content
}Twig (runtime notes)
{% include 'box/Box.html.twig' with { tag: 'section', class: 'p-4 bg-card text-card-foreground', children: 'Content' } only %}Latte (runtime notes)
{include 'box/Box.latte', tag: 'section', class: 'p-4 bg-card text-card-foreground', children: 'Content'}Jinja2 (runtime notes)
{% with p = {'Tag': 'section', 'Class': 'p-4 bg-card text-card-foreground'}, children = 'Content' %}{% include 'ui/box/box.html.j2' %}{% endwith %}MiniJinja (Rust) (runtime notes)
{% import 'ui8kit.html' as ui %}
{{ ui.box({'Tag': 'section', 'Class': 'p-4 bg-card text-card-foreground'}, children='Content') }}