feat(layout): canon demos + morfos for the remaining 6 primitives

Replicates the box / flex canonical pattern across grid, stack, group,
wrap, container and section. Each gets:

- `src/uix/morfo/components/{name}.ts` — scope `eidos`, single Provider
  part, no events. Header comment justifies the 0-event surface as a
  passive container composing through Box / Flex.
- Rewritten demo following DEMO_AUTHORING_GUIDE: 6 tabs (Live · API ·
  Morfo · Sema · Recipe · A11y), `Layout · {Name}` eyebrow, 4 meta
  pills, permanent stage between header and tablist, trace strip,
  MutationObserver wired to data-event, reactive soma + eidos snippets,
  API tables grouped by concern, reference comparison vs radix-themes
  / chakra-ui / mantine.

Cross-references in every lede + API tab:
- Grid → Box (item placement) + Flex (flex containers)
- Stack → Flex (full API) + Group (row cluster)
- Group → Stack / Wrap / Flex
- Wrap → Flex (`wrap="wrap"`) + Group (nowrap)
- Container → Box (arbitrary maxWidth) + Section (block padding)
- Section → Box (non-semantic padding) + Container (max-width)

Demo sizes: grid 479L, stack 426L, group 458L, wrap 460L, container
415L, section 386L (vs 80-95L before — matches drawer/avatar canon
mass).

svelte-check: 0 errors, 0 new warnings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
active-uix
dev 5 months ago
parent 0dc9c523d1
commit 591b08853a

@ -0,0 +1,30 @@
import type { Morfo } from '../types';
/**
* Container — max-width centred content shell (layout primitive).
*
* Eidos-native: caps content width at the `--container-width-{size}`
* token and centers via auto inline margins. The provider is a single
* `<div data-box data-container>` shell — Container composes through
* `<Box>`.
*
* No semantic events — Container is a passive container that constrains
* its children. See `box.ts` for the same 0-event justification.
*/
export const containerMorfo = {
name: 'Container',
kebab: 'container',
scope: ['eidos'],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
data: [],
aria: []
}
]
} as const satisfies Morfo;

@ -0,0 +1,30 @@
import type { Morfo } from '../types';
/**
* Grid — `display:grid` container (layout primitive).
*
* Eidos-native: every container-side grid prop maps to a `--grid-*` CSS
* variable; the provider is a single `<div data-box data-grid>` shell —
* Grid composes through `<Box>`. Item-side placement props (`gridColumn`,
* `gridRow`, `gridArea`, `placeSelf`) live on `<Box>` — see `box.ts`.
*
* No semantic events — Grid is a passive container that arranges its
* children. See `box.ts` for the same 0-event justification.
*/
export const gridMorfo = {
name: 'Grid',
kebab: 'grid',
scope: ['eidos'],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
data: [],
aria: []
}
]
} as const satisfies Morfo;

@ -0,0 +1,30 @@
import type { Morfo } from '../types';
/**
* Group — inline cluster (layout primitive).
*
* Eidos-native: a flex row by default with two cluster-specific
* behaviors (`grow` for equal-width children, `attached` for edge-to-edge
* segmented controls). The provider is a single `<div data-box data-flex
* data-group>` shell — Group composes through `<Flex>`.
*
* No semantic events — Group is a passive container that arranges its
* children. See `box.ts` for the same 0-event justification.
*/
export const groupMorfo = {
name: 'Group',
kebab: 'group',
scope: ['eidos'],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
data: [],
aria: []
}
]
} as const satisfies Morfo;

@ -0,0 +1,31 @@
import type { Morfo } from '../types';
/**
* Section — block-axis padded region (layout primitive).
*
* Eidos-native: applies a `padding-block` keyed off `size` (sm/md/lg/xl).
* Currently renders as `<div>` — until an `as` prop is added, consumers
* who need a real `<section>` landmark wrap or nest one. The provider is
* a single `<div data-box data-section>` shell — Section composes through
* `<Box>`.
*
* No semantic events — Section is a passive container that pads its
* children. See `box.ts` for the same 0-event justification.
*/
export const sectionMorfo = {
name: 'Section',
kebab: 'section',
scope: ['eidos'],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
data: [],
aria: []
}
]
} as const satisfies Morfo;

@ -0,0 +1,30 @@
import type { Morfo } from '../types';
/**
* Stack — direction-controlled flex stack (layout primitive).
*
* Eidos-native: a thin specialization of `<Flex>` that defaults
* `direction` to `column` and routes `gap`/`align`/`justify` through the
* Flex container channel. The provider is a single `<div data-box
* data-flex data-stack>` shell — Stack composes through `<Flex>`.
*
* No semantic events — Stack is a passive container that arranges its
* children. See `box.ts` for the same 0-event justification.
*/
export const stackMorfo = {
name: 'Stack',
kebab: 'stack',
scope: ['eidos'],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
data: [],
aria: []
}
]
} as const satisfies Morfo;

@ -0,0 +1,30 @@
import type { Morfo } from '../types';
/**
* Wrap — always-wrapping flex row (layout primitive).
*
* Eidos-native: a flex row that locks `flex-wrap: wrap`. Use for tag
* clusters, chip rows or anything that should reflow on narrow viewports.
* The provider is a single `<div data-box data-flex data-wrap>` shell —
* Wrap composes through `<Flex>`.
*
* No semantic events — Wrap is a passive container that arranges its
* children. See `box.ts` for the same 0-event justification.
*/
export const wrapMorfo = {
name: 'Wrap',
kebab: 'wrap',
scope: ['eidos'],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
data: [],
aria: []
}
]
} as const satisfies Morfo;

@ -1,8 +1,101 @@
<script lang="ts">
import { Container, type ContainerSize } from '$uix/eidos/components/container';
import {
Container,
type ContainerProps,
type ContainerSize,
type ContainerAlign
} from '$uix/eidos/components/container';
import { Box } from '$uix/eidos/components/box';
import { compileMorfo } from '$uix/morfo';
import { containerMorfo } from '@/uix/morfo/components/container';
const sizes: ContainerSize[] = ['sm', 'md', 'lg', 'xl', 'xxl', 'full'];
let size = $state<ContainerSize>('lg');
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
type TraceEntry = { event: string; family: string; intent?: string; at: number };
let tab = $state<Tab>('live');
let trace = $state<TraceEntry[]>([]);
let stageRef = $state<HTMLElement | null>(null);
// ── Live state — Container props ──────────────────────────────────────
let size = $state<ContainerSize>('md');
let align = $state<ContainerAlign>('center');
let paddingX = $state<string>('');
let paddingY = $state<number>(4);
const sizeOptions: readonly ContainerSize[] = ['sm', 'md', 'lg', 'xl', 'xxl', 'full'];
const alignOptions: readonly ContainerAlign[] = ['left', 'center', 'right'];
const containerProps = $derived<Partial<ContainerProps>>({
size,
align,
paddingX: paddingX || undefined,
paddingY
});
// ── Compiled morfo ────────────────────────────────────────────────────
const compiled = compileMorfo(containerMorfo);
const partsList = $derived([...compiled.parts.byKebab.values()]);
const events = $derived([...compiled.actions.byName.values()]);
$effect(() => {
const el = stageRef;
if (!el) return;
const obs = new MutationObserver((mutations) => {
for (const m of mutations) {
if (m.attributeName !== 'data-event') continue;
const target = m.target as Element;
const ev = target.getAttribute('data-event');
if (!ev) continue;
trace = [
{
event: ev,
family: target.getAttribute('data-event-family') ?? '—',
intent: target.getAttribute('data-event-intent') ?? undefined,
at: Date.now()
},
...trace
].slice(0, 6);
}
});
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
return () => obs.disconnect();
});
// ── Code snippets ─────────────────────────────────────────────────────
const somaSnippet = $derived(
[
'<!-- Container is eidos-native — no soma layer. -->',
'<!-- Equivalent semantic markup (not real soma): -->',
'',
'<div',
' data-box',
' data-container',
` data-size="${size}"`,
` data-align="${align}"`,
' style="inline-size: 100%; max-inline-size: var(--container-width-' + size + '); margin-inline: auto; padding-inline: var(--container-padding-inline);"',
'>',
' …',
'</div>'
].join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { Container } from '$uix/eidos/components/container';",
'</' + 'script>',
'',
'<Container',
size !== 'xl' && ` size="${size}"`,
align !== 'center' && ` align="${align}"`,
paddingX && ` paddingX="${paddingX}"`,
paddingY > 0 && ` paddingY={${paddingY}}`,
'>',
' …',
'</Container>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
@ -10,73 +103,313 @@
<div data-uix-eyebrow>Layout · Container</div>
<h1 data-uix-page-title>Container</h1>
<p data-uix-page-lede>
Max-width content container. Caps content at the
<code>--container-width-{'{size}'}</code> token and centers it.
Max-width centred content shell. Caps content at one of six tokens
(<code>sm · md · lg · xl · xxl · full</code>), applies a default horizontal padding via
<code>--container-padding-inline</code>, and centres via auto inline margins (or
<code>align="left"</code> / <code>align="right"</code>). For arbitrary
<code>max-width</code> values use <a href="/uix/components/box">&lt;Box&gt;</a> directly;
for semantic block padding use <a href="/uix/components/section">&lt;Section&gt;</a>.
</p>
<div data-uix-page-meta>
<span data-uix-meta-pill>
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>events</span>0
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>sizes</span>{sizeOptions.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>scope</span>eidos
</span>
</div>
</header>
<section>
<h2>Live example</h2>
<div style="display: flex; gap: 8px; margin-bottom: 12px">
{#each sizes as s (s)}
<label style="display: inline-flex; gap: 4px; align-items: center">
<input type="radio" name="size" value={s} bind:group={size} />
<span><code>{s}</code></span>
</label>
{/each}
</div>
<Container
{size}
padding={4}
style="background: var(--color-surface-1); border: 1px dashed var(--color-border); border-radius: 8px"
<!-- Live preview always rendered -->
<div data-uix-stage>
<div
data-uix-stage-area
bind:this={stageRef}
style="background: repeating-linear-gradient(45deg, transparent 0 8px, var(--color-surface-2) 8px 9px); inline-size: 100%;"
>
<p style="margin: 0">Container content (size: <code>{size}</code>).</p>
</Container>
</section>
<section>
<h2>Props</h2>
<table>
<thead>
<tr>
<th>Prop</th>
<th>Default</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>size</code></td>
<td>'xl'</td>
<td>sm · md · lg · xl · xxl · full</td>
</tr>
<tr>
<td><code>align</code></td>
<td>'center'</td>
<td>left · center · right</td>
</tr>
<tr>
<td><code>paddingX</code></td>
<td><code>var(--container-padding-inline)</code></td>
<td>override per-instance</td>
</tr>
<tr>
<td colspan="3"><em>… plus every <code>BoxProps</code> prop</em></td>
</tr>
</tbody>
</table>
</section>
<section>
<h2>Reference</h2>
<ul>
<li>
<strong>radix-themes Container</strong> — same surface; sizes map to fixed
pixel widths via tokens.
</li>
<li>
<strong>chakra-ui Container</strong> — origin of the centered max-width pattern.
</li>
</ul>
</section>
<Container
{...containerProps}
style="border: 1px dashed var(--color-border-default); border-radius: var(--radius-md); background: var(--color-surface-1);"
>
<Box
padding={3}
style="border: 1px solid var(--color-primary-border); border-radius: var(--radius-sm); background: var(--color-primary-track); color: var(--color-primary-text); text-align: center;"
>
Content (max-width: var(--container-width-{size}))
</Box>
</Container>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
<span>{trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`}</span>
<span style="color: var(--uix-text-faint)">·</span>
<span data-uix-stage-trace-key>size</span>
<span>{size}</span>
<span style="margin-inline-start: auto;">
<span data-uix-stage-trace-key>align</span> {align} ·
<span data-uix-stage-trace-key>paddingY</span> {paddingY}
</span>
</div>
</div>
<div data-uix-tabs role="tablist">
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
API <span data-uix-tab-count>4</span>
</button>
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
<span data-uix-layer-badge="morfo">morfo</span>
<span data-uix-tab-count>{partsList.length}p · 0e</span>
</button>
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
<span data-uix-layer-badge="sema">sema</span>
<span data-uix-tab-count>{events.length}</span>
</button>
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
</div>
{#if tab === 'live'}
<section data-uix-section>
<h2 data-uix-section-title>Controls</h2>
<p data-uix-section-desc>
Container is eidos-native — no <span data-uix-layer-badge="soma">soma</span> split.
The hatched background of the stage shows the parent's width; the bordered region is
what Container caps. <code>full</code> removes the cap entirely. Container also
inherits every <a href="/uix/components/box">Box</a> prop (padding, margin) via
composition.
</p>
<div data-uix-subsection-head>
<span data-uix-layer-badge="eidos">eidos</span> props · width &amp; alignment
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>size <span data-uix-control-hint>→ var(--container-width-N)</span></span>
<span data-uix-chips role="radiogroup">
{#each sizeOptions as opt}
<button data-uix-chip data-active={size === opt} onclick={() => (size = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>align <span data-uix-control-hint>horizontal alignment within parent</span></span>
<span data-uix-chips role="radiogroup">
{#each alignOptions as opt}
<button data-uix-chip data-active={align === opt} onclick={() => (align = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>paddingX <span data-uix-control-hint>override default inline padding</span></span>
<input
type="text"
placeholder="(token default)"
bind:value={paddingX}
style="inline-size: 12rem;"
/>
</label>
<label data-uix-control>
<span data-uix-control-label>paddingY <span data-uix-control-hint>0–8 → var(--space-N)</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={paddingY}
style="inline-size: 6rem;"
/>
</label>
</div>
<!-- ── Code snippets per layer ─────────────────────────────────── -->
<div data-uix-code>
<div data-uix-code-head>
<span data-uix-layer-badge="soma">soma</span>
<span>n/a · container is eidos-native — equivalent markup shown</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{somaSnippet}</code></pre>
</div>
<div data-uix-code style="margin-top: var(--uix-space-3);">
<div data-uix-code-head>
<span data-uix-layer-badge="eidos">eidos</span>
<span>visual · size token + auto inline margins</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{eidosSnippet}</code></pre>
</div>
</section>
{/if}
{#if tab === 'api'}
<section data-uix-section>
<h2 data-uix-section-title>API reference</h2>
<p data-uix-section-desc>
Container layers <code>max-inline-size</code>, <code>padding-inline</code> and
<code>margin-inline</code> rules on top of <a href="/uix/components/box"
><code>&lt;Box&gt;</code></a
>. Sizes are tokens defined in the eidos foundation; <code>full</code> removes the cap
(<code>max-width: none</code>). For arbitrary <code>max-width</code> values pass
<code>maxWidth</code> on Box directly.
</p>
<div data-uix-subsection-head>Width &amp; alignment</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">size</td><td class="type">sm | md | lg | xl | xxl | full</td><td class="default">'xl'</td><td>Maps to <code>--container-width-{`{size}`}</code> token. <code>full</code> uncaps.</td></tr>
<tr><td class="name">align</td><td class="type">left | center | right</td><td class="default">'center'</td><td>Drives <code>margin-inline</code>: <code>auto</code>/<code>0</code> combinations.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Padding</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">paddingX</td><td class="type">number | string</td><td class="default">'var(--container-padding-inline)'</td><td>Default comes from the foundation token; override per-instance.</td></tr>
<tr><td class="name">paddingY</td><td class="type">number | string</td><td class="default empty">—</td><td>Inherited from Box; default is 0. Use <a href="/uix/components/section">&lt;Section&gt;</a> if you want token-keyed block padding.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Inherited from Box</div>
<p data-uix-section-desc>
Every <a href="/uix/components/box">BoxProps</a> field is forwarded:
<code>padding*</code>, <code>margin*</code>, <code>width</code> (locked to 100% by
Container), <code>height</code>, <code>position</code>, <code>overflow*</code>. Note
that Container sets <code>marginLeft</code> / <code>marginRight</code> from
<code>align</code>, so manual <code>marginX</code> overrides override the alignment.
</p>
<div data-uix-subsection-head>Reference comparison</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Library</th><th>Closest equivalent</th><th>Difference</th></tr></thead>
<tbody>
<tr><td class="name">radix-themes</td><td><code>&lt;Container&gt;</code></td><td>Radix exposes 4 sizes (<code>1..4</code>); UIX uses 6 named tokens (<code>sm..xxl</code> + <code>full</code>). Same centred-by-default shape.</td></tr>
<tr><td class="name">chakra-ui</td><td><code>&lt;Container&gt;</code></td><td>Chakra defaults to <code>maxW="60ch"</code> regardless of theme; UIX wires through to foundation tokens for project-wide consistency.</td></tr>
<tr><td class="name">mantine</td><td><code>&lt;Container&gt;</code></td><td>Mantine takes <code>size="xs|sm|md|lg|xl"</code> or a raw number; UIX matches the named scale and adds <code>full</code> to opt out.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'morfo'}
<section data-uix-section>
<h2 data-uix-section-title>Morfo contract</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Field</th><th>Value</th></tr></thead>
<tbody>
<tr><td class="name">name</td><td>{containerMorfo.name}</td></tr>
<tr><td class="name">kebab</td><td><code>{containerMorfo.kebab}</code></td></tr>
<tr><td class="name">scope</td><td>{containerMorfo.scope.join(', ')}</td></tr>
<tr><td class="name">parts</td><td>{partsList.length}</td></tr>
<tr><td class="name">events</td><td>0</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Parts</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>kebab</th><th>marker</th><th>element</th><th>archetype</th><th>optional</th></tr></thead>
<tbody>
{#each partsList as part}
<tr>
<td class="name">{part.kebab}</td>
<td><code data-uix-part-marker>[{part.marker}]</code></td>
<td class="type">&lt;{part.defaultElement}&gt;</td>
<td class="type">{part.archetype}</td>
<td class="default">{part.optional ? 'yes' : 'no'}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<p data-uix-section-desc style="margin-top: var(--uix-space-4);">
Container composes through <code>&lt;Box&gt;</code>, so the rendered DOM is a single
<code>div[data-box][data-container]</code> shell with <code>data-size</code> and
<code>data-align</code> attributes for selector targeting.
</p>
</section>
{/if}
{#if tab === 'sema'}
<section data-uix-section>
<h2 data-uix-section-title>
<span data-uix-layer-badge="sema">sema</span> · events
</h2>
<p data-uix-section-desc>
Container declares no semantic events. As a passive layout primitive, it does not
commit, emerge, or react to anything — it just constrains its children's width.
Content inside the container owns its own sema.
</p>
</section>
{/if}
{#if tab === 'recipe'}
<section data-uix-section>
<h2 data-uix-section-title>Eidos recipe</h2>
<p data-uix-section-desc>
Container reads <code>--container-width-{`{size}`}</code> and
<code>--container-padding-inline</code> from the eidos foundation. The Svelte
component computes the resolved width and margins inline; the recipe at
<code>src/uix/eidos/components/container/container.css</code> mostly carries the
marker.
</p>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Selector</th><th>Owner</th><th>Purpose</th></tr></thead>
<tbody>
<tr>
<td class="name"><code>[data-container]</code></td>
<td><span data-uix-tag data-kind="morfo">morfo</span></td>
<td>Provider marker.</td>
</tr>
<tr>
<td class="name"><code>[data-container][data-size='{`{size}`}']</code></td>
<td><span data-uix-tag data-kind="eidos">eidos</span></td>
<td>Per-size hooks (currently used by the component's inline style, available for consumer overrides).</td>
</tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'a11y'}
<section data-uix-section>
<h2 data-uix-section-title>Accessibility</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Concern</th><th>Contract</th></tr></thead>
<tbody>
<tr><td class="name">Role</td><td>None implicit. Default element is <code>&lt;div&gt;</code> — semantically neutral. Container is a layout wrapper; landmarks (<code>&lt;main&gt;</code>, <code>&lt;article&gt;</code>) belong on a separate element.</td></tr>
<tr><td class="name">Label</td><td>Not applicable.</td></tr>
<tr><td class="name">Keyboard</td><td>Container is not focusable. Tab order follows DOM order.</td></tr>
<tr><td class="name">Reduced motion</td><td>Container does not animate.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

@ -1,9 +1,114 @@
<script lang="ts">
import { Grid } from '$uix/eidos/components/grid';
import { Grid, type GridProps } from '$uix/eidos/components/grid';
import { Box } from '$uix/eidos/components/box';
import { compileMorfo } from '$uix/morfo';
import { gridMorfo } from '@/uix/morfo/components/grid';
const cellStyle =
'background: var(--color-surface-2); border-radius: 4px; padding: 12px; text-align: center';
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
type TraceEntry = { event: string; family: string; intent?: string; at: number };
let tab = $state<Tab>('live');
let trace = $state<TraceEntry[]>([]);
let stageRef = $state<HTMLElement | null>(null);
// ── Live state — Grid container props ────────────────────────────────
let templateColumns = $state<string>('repeat(3, 1fr)');
let autoFlow = $state<'row' | 'column' | 'dense' | 'row dense' | 'column dense'>('row');
let align = $state<'stretch' | 'start' | 'center' | 'end' | 'baseline'>('stretch');
let justify = $state<
'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch'
>('start');
let gap = $state<number>(3);
let padding = $state<number>(4);
const autoFlowOptions = ['row', 'column', 'dense', 'row dense', 'column dense'] as const;
const alignOptions = ['stretch', 'start', 'center', 'end', 'baseline'] as const;
const justifyOptions = [
'start',
'center',
'end',
'space-between',
'space-around',
'space-evenly',
'stretch'
] as const;
const gridProps = $derived<Partial<GridProps>>({
templateColumns: templateColumns || undefined,
autoFlow,
align,
justify,
gap,
padding
});
// ── Compiled morfo ────────────────────────────────────────────────────
const compiled = compileMorfo(gridMorfo);
const partsList = $derived([...compiled.parts.byKebab.values()]);
const events = $derived([...compiled.actions.byName.values()]);
$effect(() => {
const el = stageRef;
if (!el) return;
const obs = new MutationObserver((mutations) => {
for (const m of mutations) {
if (m.attributeName !== 'data-event') continue;
const target = m.target as Element;
const ev = target.getAttribute('data-event');
if (!ev) continue;
trace = [
{
event: ev,
family: target.getAttribute('data-event-family') ?? '—',
intent: target.getAttribute('data-event-intent') ?? undefined,
at: Date.now()
},
...trace
].slice(0, 6);
}
});
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
return () => obs.disconnect();
});
// ── Code snippets ─────────────────────────────────────────────────────
const somaSnippet = $derived(
[
'<!-- Grid is eidos-native — no soma layer. -->',
'<!-- Equivalent semantic markup (not real soma): -->',
'',
'<div',
' data-box',
' data-grid',
' style="display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3);"',
'>',
' …',
'</div>'
].join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { Grid } from '$uix/eidos/components/grid';",
" import { Box } from '$uix/eidos/components/box';",
'</' + 'script>',
'',
'<Grid',
templateColumns !== 'repeat(3, 1fr)' && ` templateColumns="${templateColumns}"`,
autoFlow !== 'row' && ` autoFlow="${autoFlow}"`,
align !== 'stretch' && ` align="${align}"`,
justify !== 'start' && ` justify="${justify}"`,
gap > 0 && ` gap={${gap}}`,
padding > 0 && ` padding={${padding}}`,
'>',
' <Box gridColumn="span 2">A</Box>',
' <Box>B</Box>',
' …',
'</Grid>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
@ -11,82 +116,364 @@
<div data-uix-eyebrow>Layout · Grid</div>
<h1 data-uix-page-title>Grid</h1>
<p data-uix-page-lede>
<code>display:grid</code> container with track and placement props.
<code>display:grid</code> container. Owns track templates
(<code>templateColumns</code>, <code>templateRows</code>,
<code>autoColumns</code>, <code>autoRows</code>, <code>autoFlow</code>), container alignment
(<code>align</code>, <code>justify</code>, <code>placeItems</code>,
<code>placeContent</code>) and the row/column gap. <strong>Item placement</strong> props
(<code>gridColumn</code>, <code>gridRow</code>, <code>gridArea</code>,
<code>placeSelf</code>) live on the child <a href="/uix/components/box">&lt;Box&gt;</a>.
For flex layouts use <a href="/uix/components/flex">&lt;Flex&gt;</a>.
</p>
<div data-uix-page-meta>
<span data-uix-meta-pill>
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>events</span>0
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>extends</span>Box
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>scope</span>eidos
</span>
</div>
</header>
<section>
<h2>Live example</h2>
<Grid
templateColumns="repeat(3, 1fr)"
gap={3}
padding={4}
style="background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: 8px"
>
<Box style={cellStyle}>1</Box>
<Box style={cellStyle}>2</Box>
<Box style={cellStyle}>3</Box>
<Box style={cellStyle}>4</Box>
<Box style={cellStyle}>5</Box>
<Box style={cellStyle}>6</Box>
</Grid>
</section>
<section>
<h2>Props</h2>
<table>
<thead>
<tr>
<th>Prop</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>templateColumns</code> / <code>templateRows</code></td>
<td>raw <code>grid-template-*</code> strings</td>
</tr>
<tr>
<td><code>autoColumns</code> / <code>autoRows</code></td>
<td>implicit track sizes</td>
</tr>
<tr>
<td><code>autoFlow</code></td>
<td>row · column · dense · row dense · column dense</td>
</tr>
<tr>
<td><code>gap</code> / <code>rowGap</code> / <code>columnGap</code></td>
<td>row/columnGap override <code>gap</code> per axis</td>
</tr>
<tr>
<td><code>align</code> / <code>justify</code></td>
<td><code>align-items</code> / <code>justify-content</code></td>
</tr>
<tr>
<td><code>placeItems</code> / <code>placeContent</code></td>
<td>raw shorthand strings</td>
</tr>
<tr>
<td><code>gridColumn</code> / <code>gridRow</code> / <code>gridArea</code></td>
<td>per-item placement</td>
</tr>
<tr>
<td colspan="2"><em>… plus every <code>BoxProps</code> prop except <code>display</code></em></td>
</tr>
</tbody>
</table>
</section>
<section>
<h2>Reference</h2>
<ul>
<li>
<strong>CSS Grid spec</strong> — props are 1:1 with the CSS properties they wrap.
</li>
<li>
<strong>radix-themes Grid</strong> — same prop names (<code>columns</code> is
called <code>templateColumns</code> here, for symmetry with <code>templateRows</code>).
</li>
</ul>
</section>
<!-- Live preview always rendered -->
<div data-uix-stage>
<div data-uix-stage-area bind:this={stageRef}>
<Grid
{...gridProps}
style="border: 1px dashed var(--color-border-default); border-radius: var(--radius-md); min-block-size: 10rem; min-inline-size: 24rem;"
>
<Box
padding={2}
style="border: 1px solid var(--color-primary-border); border-radius: var(--radius-sm); background: var(--color-primary-track); color: var(--color-primary-text); text-align: center;"
>1</Box>
<Box
padding={2}
style="border: 1px solid var(--color-affirm-border); border-radius: var(--radius-sm); background: var(--color-affirm-track); color: var(--color-affirm-text); text-align: center;"
>2</Box>
<Box
padding={2}
style="border: 1px solid var(--color-risk-border); border-radius: var(--radius-sm); background: var(--color-risk-track); color: var(--color-risk-text); text-align: center;"
>3</Box>
<Box
padding={2}
style="border: 1px solid var(--color-primary-border); border-radius: var(--radius-sm); background: var(--color-primary-track); color: var(--color-primary-text); text-align: center;"
>4</Box>
<Box
padding={2}
style="border: 1px solid var(--color-affirm-border); border-radius: var(--radius-sm); background: var(--color-affirm-track); color: var(--color-affirm-text); text-align: center;"
>5</Box>
<Box
padding={2}
style="border: 1px solid var(--color-risk-border); border-radius: var(--radius-sm); background: var(--color-risk-track); color: var(--color-risk-text); text-align: center;"
>6</Box>
</Grid>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
<span>{trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`}</span>
<span style="color: var(--uix-text-faint)">·</span>
<span data-uix-stage-trace-key>templateColumns</span>
<span>{templateColumns}</span>
<span style="margin-inline-start: auto;">
<span data-uix-stage-trace-key>gap</span> {gap} ·
<span data-uix-stage-trace-key>autoFlow</span> {autoFlow}
</span>
</div>
</div>
<div data-uix-tabs role="tablist">
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
API <span data-uix-tab-count>12+</span>
</button>
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
<span data-uix-layer-badge="morfo">morfo</span>
<span data-uix-tab-count>{partsList.length}p · 0e</span>
</button>
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
<span data-uix-layer-badge="sema">sema</span>
<span data-uix-tab-count>{events.length}</span>
</button>
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
</div>
{#if tab === 'live'}
<section data-uix-section>
<h2 data-uix-section-title>Controls</h2>
<p data-uix-section-desc>
Grid is eidos-native — no <span data-uix-layer-badge="soma">soma</span> split. The
container props below map to <code>--grid-*</code> CSS variables. Grid also inherits
every <a href="/uix/components/box">Box</a> prop (padding, margin, size, position) by
composition. Item-side placement (<code>gridColumn</code>, <code>gridRow</code>,
<code>gridArea</code>, <code>placeSelf</code>) is set on the child Box.
</p>
<div data-uix-subsection-head>
<span data-uix-layer-badge="eidos">eidos</span> props · container behaviour
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>templateColumns <span data-uix-control-hint>e.g. repeat(3, 1fr)</span></span>
<input
type="text"
placeholder="(none)"
bind:value={templateColumns}
style="inline-size: 14rem;"
/>
</label>
<label data-uix-control>
<span data-uix-control-label>autoFlow</span>
<span data-uix-chips role="radiogroup">
{#each autoFlowOptions as opt}
<button data-uix-chip data-active={autoFlow === opt} onclick={() => (autoFlow = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>align <span data-uix-control-hint>align-items</span></span>
<span data-uix-chips role="radiogroup">
{#each alignOptions as opt}
<button data-uix-chip data-active={align === opt} onclick={() => (align = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>justify <span data-uix-control-hint>justify-content</span></span>
<span data-uix-chips role="radiogroup">
{#each justifyOptions as opt}
<button data-uix-chip data-active={justify === opt} onclick={() => (justify = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>gap <span data-uix-control-hint>0–8 → var(--space-N)</span></span>
<input type="number" min="0" max="8" step="1" bind:value={gap} style="inline-size: 6rem;" />
</label>
<label data-uix-control>
<span data-uix-control-label>padding <span data-uix-control-hint>inherited from Box</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={padding}
style="inline-size: 6rem;"
/>
</label>
</div>
<!-- ── Code snippets per layer ─────────────────────────────────── -->
<div data-uix-code>
<div data-uix-code-head>
<span data-uix-layer-badge="soma">soma</span>
<span>n/a · grid is eidos-native — equivalent markup shown</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{somaSnippet}</code></pre>
</div>
<div data-uix-code style="margin-top: var(--uix-space-3);">
<div data-uix-code-head>
<span data-uix-layer-badge="eidos">eidos</span>
<span>visual · container props mapped to --grid-* CSS variables</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{eidosSnippet}</code></pre>
</div>
</section>
{/if}
{#if tab === 'api'}
<section data-uix-section>
<h2 data-uix-section-title>API reference</h2>
<p data-uix-section-desc>
Grid adds container-side grid props on top of every <code>BoxProps</code> field. Track
templates accept any CSS <code>grid-template-*</code> string. <strong>Item placement</strong>
props (<code>gridColumn</code>, <code>gridRow</code>, <code>gridArea</code>,
<code>placeSelf</code>) live on the child <a href="/uix/components/box"><code>&lt;Box&gt;</code></a>.
</p>
<div data-uix-subsection-head>Track templates</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">templateColumns</td><td class="type">string</td><td class="default empty">—</td><td><code>grid-template-columns</code>. e.g. <code>"repeat(3, 1fr)"</code>.</td></tr>
<tr><td class="name">templateRows</td><td class="type">string</td><td class="default empty">—</td><td><code>grid-template-rows</code>.</td></tr>
<tr><td class="name">autoColumns</td><td class="type">string</td><td class="default">'auto'</td><td><code>grid-auto-columns</code>.</td></tr>
<tr><td class="name">autoRows</td><td class="type">string</td><td class="default">'auto'</td><td><code>grid-auto-rows</code>.</td></tr>
<tr><td class="name">autoFlow</td><td class="type">row | column | dense | row dense | column dense</td><td class="default">'row'</td><td><code>grid-auto-flow</code>.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Alignment</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">align</td><td class="type">stretch | start | center | end | baseline | flex-start | flex-end</td><td class="default">'stretch'</td><td><code>align-items</code>.</td></tr>
<tr><td class="name">justify</td><td class="type">start | center | end | stretch | space-between | space-around | space-evenly | flex-start | flex-end</td><td class="default">'start'</td><td><code>justify-content</code>.</td></tr>
<tr><td class="name">placeItems</td><td class="type">string</td><td class="default empty">—</td><td>Shorthand for <code>align-items</code> + <code>justify-items</code>.</td></tr>
<tr><td class="name">placeContent</td><td class="type">string</td><td class="default empty">—</td><td>Shorthand for <code>align-content</code> + <code>justify-content</code>.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Gap</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">gap</td><td class="type">number | string</td><td class="default empty">—</td><td>Shorthand for both axes. Number → <code>var(--space-N)</code>.</td></tr>
<tr><td class="name">rowGap</td><td class="type">number | string</td><td class="default empty">—</td><td>Per-axis override; takes precedence over <code>gap</code>.</td></tr>
<tr><td class="name">columnGap</td><td class="type">number | string</td><td class="default empty">—</td><td>Per-axis override; takes precedence over <code>gap</code>.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Inherited from Box</div>
<p data-uix-section-desc>
Every <a href="/uix/components/box">BoxProps</a> field is forwarded (except
<code>display</code>, which Grid locks to <code>grid</code>):
<code>padding*</code>, <code>margin*</code>, <code>width</code>, <code>height</code>,
<code>position</code>, <code>top/right/bottom/left</code>, <code>overflow*</code>.
</p>
<div data-uix-subsection-head>Item placement (on child Box)</div>
<p data-uix-section-desc>
Item-side props are not on Grid. Set them on the child Box:
<code>gridColumn</code>, <code>gridRow</code>, <code>gridArea</code>,
<code>placeSelf</code>, <code>alignSelf</code>, <code>justifySelf</code>, <code>order</code>.
See <a href="/uix/components/box">&lt;Box&gt;</a> → "Flex / grid item".
</p>
<div data-uix-subsection-head>Reference comparison</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Library</th><th>Closest equivalent</th><th>Difference</th></tr></thead>
<tbody>
<tr><td class="name">radix-themes</td><td><code>&lt;Grid&gt;</code></td><td>Same shape: container props on Grid, item props on Box. Radix accepts <code>columns="3"</code> shorthand; UIX uses raw <code>templateColumns="repeat(3, 1fr)"</code>.</td></tr>
<tr><td class="name">chakra-ui</td><td><code>&lt;Grid&gt;</code> / <code>&lt;GridItem&gt;</code></td><td>Chakra ships a separate <code>&lt;GridItem&gt;</code> for placement; UIX uses Box on the child instead — one primitive, less indirection.</td></tr>
<tr><td class="name">mantine</td><td><code>&lt;SimpleGrid&gt;</code> / <code>&lt;Grid&gt;</code></td><td>Mantine splits into SimpleGrid (auto-fit responsive) and Grid (12-col span); UIX keeps a single Grid that accepts arbitrary CSS Grid templates.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'morfo'}
<section data-uix-section>
<h2 data-uix-section-title>Morfo contract</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Field</th><th>Value</th></tr></thead>
<tbody>
<tr><td class="name">name</td><td>{gridMorfo.name}</td></tr>
<tr><td class="name">kebab</td><td><code>{gridMorfo.kebab}</code></td></tr>
<tr><td class="name">scope</td><td>{gridMorfo.scope.join(', ')}</td></tr>
<tr><td class="name">parts</td><td>{partsList.length}</td></tr>
<tr><td class="name">events</td><td>0</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Parts</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>kebab</th><th>marker</th><th>element</th><th>archetype</th><th>optional</th></tr></thead>
<tbody>
{#each partsList as part}
<tr>
<td class="name">{part.kebab}</td>
<td><code data-uix-part-marker>[{part.marker}]</code></td>
<td class="type">&lt;{part.defaultElement}&gt;</td>
<td class="type">{part.archetype}</td>
<td class="default">{part.optional ? 'yes' : 'no'}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<p data-uix-section-desc style="margin-top: var(--uix-space-4);">
Grid composes through <code>&lt;Box&gt;</code>, so the rendered DOM is a single
<code>div[data-box][data-grid]</code> shell. Recipe lives at
<code>src/uix/eidos/components/grid/grid.css</code> and layers on top of the Box recipe.
</p>
</section>
{/if}
{#if tab === 'sema'}
<section data-uix-section>
<h2 data-uix-section-title>
<span data-uix-layer-badge="sema">sema</span> · events
</h2>
<p data-uix-section-desc>
Grid declares no semantic events. As a passive layout primitive, it does not commit,
emerge, or react to anything — it just arranges its children. Components that animate
on appearance should compose Grid with an interactive primitive (popover, drawer,
collapsible) that owns the relevant sema verbs.
</p>
</section>
{/if}
{#if tab === 'recipe'}
<section data-uix-section>
<h2 data-uix-section-title>Eidos recipe</h2>
<p data-uix-section-desc>
Recipe lives in <code>src/uix/eidos/components/grid/grid.css</code> and layers on top of
the Box recipe. The provider element carries both <code>data-box</code> and
<code>data-grid</code> markers because Grid renders through Box.
</p>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Selector</th><th>Owner</th><th>Purpose</th></tr></thead>
<tbody>
<tr>
<td class="name"><code>[data-grid]</code></td>
<td><span data-uix-tag data-kind="morfo">morfo</span></td>
<td>Provider marker.</td>
</tr>
<tr>
<td class="name"><code>[data-box][data-grid] {`{ grid-template-columns: var(--grid-template-columns, none); … }`}</code></td>
<td><span data-uix-tag data-kind="eidos">eidos</span></td>
<td>Layer container-side grid properties on the Box recipe.</td>
</tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'a11y'}
<section data-uix-section>
<h2 data-uix-section-title>Accessibility</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Concern</th><th>Contract</th></tr></thead>
<tbody>
<tr><td class="name">Role</td><td>None implicit. Default element is <code>&lt;div&gt;</code> — semantically neutral. Wrap Grid in a landmark (<code>&lt;main&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;section&gt;</code>) when content needs one.</td></tr>
<tr><td class="name">Label</td><td>Not applicable — Grid has no content semantics. Labels belong to the interactive children.</td></tr>
<tr><td class="name">Keyboard</td><td>Grid is not focusable. Tab order follows DOM order even when CSS Grid reflows visual order (e.g. <code>order</code>, <code>grid-area</code>, <code>autoFlow="dense"</code>). Verify visual order matches focus order for keyboard users.</td></tr>
<tr><td class="name">Reduced motion</td><td>Grid does not animate. Layout shifts on resize follow CSS defaults.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

@ -1,8 +1,115 @@
<script lang="ts">
import { Group } from '$uix/eidos/components/group';
import { Group, type GroupProps } from '$uix/eidos/components/group';
import { Box } from '$uix/eidos/components/box';
import { compileMorfo } from '$uix/morfo';
import { groupMorfo } from '@/uix/morfo/components/group';
const btnStyle =
'background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 6px; padding: 6px 12px; font: inherit';
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
type TraceEntry = { event: string; family: string; intent?: string; at: number };
let tab = $state<Tab>('live');
let trace = $state<TraceEntry[]>([]);
let stageRef = $state<HTMLElement | null>(null);
// ── Live state — Group container props ────────────────────────────────
let direction = $state<'row' | 'column'>('row');
let align = $state<'stretch' | 'start' | 'center' | 'end' | 'baseline'>('center');
let justify = $state<
'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch'
>('start');
let gap = $state<number>(2);
let grow = $state<boolean>(false);
let attached = $state<boolean>(false);
let padding = $state<number>(3);
const directionOptions = ['row', 'column'] as const;
const alignOptions = ['stretch', 'start', 'center', 'end', 'baseline'] as const;
const justifyOptions = [
'start',
'center',
'end',
'space-between',
'space-around',
'space-evenly',
'stretch'
] as const;
const groupProps = $derived<Partial<GroupProps>>({
direction,
align,
justify,
gap: attached && gap === 0 ? undefined : gap,
grow,
attached,
padding
});
// ── Compiled morfo ────────────────────────────────────────────────────
const compiled = compileMorfo(groupMorfo);
const partsList = $derived([...compiled.parts.byKebab.values()]);
const events = $derived([...compiled.actions.byName.values()]);
$effect(() => {
const el = stageRef;
if (!el) return;
const obs = new MutationObserver((mutations) => {
for (const m of mutations) {
if (m.attributeName !== 'data-event') continue;
const target = m.target as Element;
const ev = target.getAttribute('data-event');
if (!ev) continue;
trace = [
{
event: ev,
family: target.getAttribute('data-event-family') ?? '—',
intent: target.getAttribute('data-event-intent') ?? undefined,
at: Date.now()
},
...trace
].slice(0, 6);
}
});
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
return () => obs.disconnect();
});
// ── Code snippets ─────────────────────────────────────────────────────
const somaSnippet = $derived(
[
'<!-- Group is eidos-native — no soma layer. -->',
'<!-- Equivalent semantic markup (not real soma): -->',
'',
'<div',
' data-box',
' data-flex',
' data-group',
' style="display: flex; flex-direction: row; gap: var(--space-2);"',
'>',
' …',
'</div>'
].join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { Group } from '$uix/eidos/components/group';",
'</' + 'script>',
'',
'<Group',
direction !== 'row' && ` direction="${direction}"`,
align !== 'stretch' && ` align="${align}"`,
justify !== 'start' && ` justify="${justify}"`,
gap > 0 && !attached && ` gap={${gap}}`,
grow && ' grow',
attached && ' attached',
padding > 0 && ` padding={${padding}}`,
'>',
' …',
'</Group>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
@ -10,85 +117,342 @@
<div data-uix-eyebrow>Layout · Group</div>
<h1 data-uix-page-title>Group</h1>
<p data-uix-page-lede>
Inline cluster of children. Supports <code>grow</code> (equal-width children)
and <code>attached</code> (edge-merged children).
Inline cluster — flex row by default, intended for toolbars, button groups and
segmented controls. Adds two cluster-specific behaviours on top of
<a href="/uix/components/flex">&lt;Flex&gt;</a>: <code>grow</code> (every child stretches
to equal width via <code>flex: 1 1 0</code>) and <code>attached</code> (children share an
edge — used for segmented controls). For vertical clusters use
<a href="/uix/components/stack">&lt;Stack&gt;</a>; for chips that should wrap across lines
use <a href="/uix/components/wrap">&lt;Wrap&gt;</a>; for the full flex API drop down to
<code>&lt;Flex&gt;</code>.
</p>
<div data-uix-page-meta>
<span data-uix-meta-pill>
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>events</span>0
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>extends</span>Flex
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>scope</span>eidos
</span>
</div>
</header>
<section>
<h2>Default</h2>
<Group gap={2}>
<button type="button" style={btnStyle}>One</button>
<button type="button" style={btnStyle}>Two</button>
<button type="button" style={btnStyle}>Three</button>
</Group>
</section>
<section>
<h2>Attached (segmented control)</h2>
<Group attached>
<button type="button" style={btnStyle}>Day</button>
<button type="button" style={btnStyle}>Week</button>
<button type="button" style={btnStyle}>Month</button>
</Group>
</section>
<section>
<h2>Grow (equal widths)</h2>
<Group grow gap={2} style="width: 320px">
<button type="button" style={btnStyle}>Cancel</button>
<button type="button" style={btnStyle}>Save</button>
</Group>
</section>
<section>
<h2>Props</h2>
<table>
<thead>
<tr>
<th>Prop</th>
<th>Default</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>direction</code></td>
<td>'row'</td>
<td>row · column</td>
</tr>
<tr>
<td><code>grow</code></td>
<td>false</td>
<td>children get <code>flex: 1 1 0</code></td>
</tr>
<tr>
<td><code>attached</code></td>
<td>false</td>
<td>collapses inner radii + overlaps 1px to merge borders</td>
</tr>
<tr>
<td><code>gap</code></td>
<td>0 if <code>attached</code></td>
<td>defaults to <code>0</code> when <code>attached</code> is on</td>
</tr>
<tr>
<td colspan="3"><em>… plus FlexProps minus <code>wrap</code></em></td>
</tr>
</tbody>
</table>
</section>
<section>
<h2>Reference</h2>
<ul>
<li>
<strong>mantine Group</strong> — same name and intent.
</li>
<li>
<strong>chakra-ui ButtonGroup</strong> — origin of the
<code>attached</code> behavior, generalized here.
</li>
</ul>
</section>
<!-- Live preview always rendered -->
<div data-uix-stage>
<div data-uix-stage-area bind:this={stageRef}>
<Group
{...groupProps}
style="border: 1px dashed var(--color-border-default); border-radius: var(--radius-md); min-inline-size: 24rem;"
>
<Box
padding={2}
style="border: 1px solid var(--color-border-default); border-radius: var(--radius-sm); background: var(--color-surface-2);"
>One</Box>
<Box
padding={2}
style="border: 1px solid var(--color-border-default); border-radius: var(--radius-sm); background: var(--color-surface-2);"
>Two</Box>
<Box
padding={2}
style="border: 1px solid var(--color-border-default); border-radius: var(--radius-sm); background: var(--color-surface-2);"
>Three</Box>
</Group>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
<span>{trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`}</span>
<span style="color: var(--uix-text-faint)">·</span>
<span data-uix-stage-trace-key>direction</span>
<span>{direction}</span>
<span style="margin-inline-start: auto;">
<span data-uix-stage-trace-key>grow</span> {String(grow)} ·
<span data-uix-stage-trace-key>attached</span> {String(attached)}
</span>
</div>
</div>
<div data-uix-tabs role="tablist">
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
API <span data-uix-tab-count>6</span>
</button>
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
<span data-uix-layer-badge="morfo">morfo</span>
<span data-uix-tab-count>{partsList.length}p · 0e</span>
</button>
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
<span data-uix-layer-badge="sema">sema</span>
<span data-uix-tab-count>{events.length}</span>
</button>
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
</div>
{#if tab === 'live'}
<section data-uix-section>
<h2 data-uix-section-title>Controls</h2>
<p data-uix-section-desc>
Group is eidos-native — no <span data-uix-layer-badge="soma">soma</span> split. Five
container props plus two cluster-specific booleans (<code>grow</code>,
<code>attached</code>) on top of <code>&lt;Flex&gt;</code>. Wrap is intentionally
disabled — use <a href="/uix/components/wrap">&lt;Wrap&gt;</a> when you need wrapping.
</p>
<div data-uix-subsection-head>
<span data-uix-layer-badge="eidos">eidos</span> props · cluster behaviour
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>direction</span>
<span data-uix-chips role="radiogroup">
{#each directionOptions as opt}
<button
data-uix-chip
data-active={direction === opt}
onclick={() => (direction = opt)}>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>align <span data-uix-control-hint>cross-axis</span></span>
<span data-uix-chips role="radiogroup">
{#each alignOptions as opt}
<button data-uix-chip data-active={align === opt} onclick={() => (align = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>justify <span data-uix-control-hint>main-axis</span></span>
<span data-uix-chips role="radiogroup">
{#each justifyOptions as opt}
<button data-uix-chip data-active={justify === opt} onclick={() => (justify = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>gap <span data-uix-control-hint>0–8 → var(--space-N); attached locks to 0</span></span>
<input type="number" min="0" max="8" step="1" bind:value={gap} style="inline-size: 6rem;" />
</label>
<label data-uix-control>
<span data-uix-control-label>grow <span data-uix-control-hint>flex: 1 1 0 on every child</span></span>
<span data-uix-switch>
<input type="checkbox" bind:checked={grow} />
<span data-uix-switch-label>{grow ? 'on' : 'off'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>attached <span data-uix-control-hint>children share an edge</span></span>
<span data-uix-switch>
<input type="checkbox" bind:checked={attached} />
<span data-uix-switch-label>{attached ? 'on' : 'off'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>padding <span data-uix-control-hint>inherited from Box</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={padding}
style="inline-size: 6rem;"
/>
</label>
</div>
<!-- ── Code snippets per layer ─────────────────────────────────── -->
<div data-uix-code>
<div data-uix-code-head>
<span data-uix-layer-badge="soma">soma</span>
<span>n/a · group is eidos-native — equivalent markup shown</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{somaSnippet}</code></pre>
</div>
<div data-uix-code style="margin-top: var(--uix-space-3);">
<div data-uix-code-head>
<span data-uix-layer-badge="eidos">eidos</span>
<span>visual · cluster props on top of Flex</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{eidosSnippet}</code></pre>
</div>
</section>
{/if}
{#if tab === 'api'}
<section data-uix-section>
<h2 data-uix-section-title>API reference</h2>
<p data-uix-section-desc>
Group narrows <a href="/uix/components/flex"><code>&lt;Flex&gt;</code></a>'s
<code>direction</code> to <code>row | column</code> (no reverse variants), drops
<code>wrap</code> entirely (use <a href="/uix/components/wrap"
><code>&lt;Wrap&gt;</code></a
> for that), and adds two cluster-specific booleans.
</p>
<div data-uix-subsection-head>Container props</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">direction</td><td class="type">row | column</td><td class="default">'row'</td><td>Narrowed from Flex's full direction union.</td></tr>
<tr><td class="name">gap</td><td class="type">number | string</td><td class="default">attached ? 0 : —</td><td>Number → <code>var(--space-N)</code>. <code>attached</code> implies <code>gap=0</code>; explicit prop wins.</td></tr>
<tr><td class="name">align</td><td class="type">stretch | start | center | end | baseline | flex-start | flex-end</td><td class="default empty">—</td><td><code>align-items</code> — cross-axis.</td></tr>
<tr><td class="name">justify</td><td class="type">start | center | end | space-between | space-around | space-evenly | stretch | flex-start | flex-end</td><td class="default empty">—</td><td><code>justify-content</code> — main-axis.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Cluster behaviour</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">grow</td><td class="type">boolean</td><td class="default">false</td><td>Every child gets <code>flex: 1 1 0</code> — fills the row evenly.</td></tr>
<tr><td class="name">attached</td><td class="type">boolean</td><td class="default">false</td><td>Adjacent children share an edge: inner radii squared, 1px overlap absorbs doubled borders. Implies <code>gap=0</code> unless explicitly set.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Inherited from Box</div>
<p data-uix-section-desc>
Every <a href="/uix/components/box">BoxProps</a> field is forwarded through Flex:
<code>padding*</code>, <code>margin*</code>, <code>width</code>, <code>height</code>,
<code>position</code>, <code>overflow*</code>, plus item-side props.
</p>
<div data-uix-subsection-head>Reference comparison</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Library</th><th>Closest equivalent</th><th>Difference</th></tr></thead>
<tbody>
<tr><td class="name">radix-themes</td><td><code>&lt;Flex&gt;</code></td><td>Radix doesn't ship a separate Group — they recommend Flex with <code>gap</code>. UIX adds <code>attached</code> for segmented controls and <code>grow</code> for equal-width toolbars.</td></tr>
<tr><td class="name">chakra-ui</td><td><code>&lt;ButtonGroup&gt;</code> / <code>&lt;HStack&gt;</code></td><td>Chakra splits attached behaviour into ButtonGroup (button-specific). UIX's Group is element-agnostic — works for any cluster.</td></tr>
<tr><td class="name">mantine</td><td><code>&lt;Group&gt;</code></td><td>Mantine has the same name and shape; <code>grow</code> maps 1:1. Mantine doesn't have <code>attached</code> — UIX adds it.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'morfo'}
<section data-uix-section>
<h2 data-uix-section-title>Morfo contract</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Field</th><th>Value</th></tr></thead>
<tbody>
<tr><td class="name">name</td><td>{groupMorfo.name}</td></tr>
<tr><td class="name">kebab</td><td><code>{groupMorfo.kebab}</code></td></tr>
<tr><td class="name">scope</td><td>{groupMorfo.scope.join(', ')}</td></tr>
<tr><td class="name">parts</td><td>{partsList.length}</td></tr>
<tr><td class="name">events</td><td>0</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Parts</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>kebab</th><th>marker</th><th>element</th><th>archetype</th><th>optional</th></tr></thead>
<tbody>
{#each partsList as part}
<tr>
<td class="name">{part.kebab}</td>
<td><code data-uix-part-marker>[{part.marker}]</code></td>
<td class="type">&lt;{part.defaultElement}&gt;</td>
<td class="type">{part.archetype}</td>
<td class="default">{part.optional ? 'yes' : 'no'}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<p data-uix-section-desc style="margin-top: var(--uix-space-4);">
Group composes through <code>&lt;Flex&gt;</code> which composes through
<code>&lt;Box&gt;</code>, so the rendered DOM is a single
<code>div[data-box][data-flex][data-group]</code> shell with optional
<code>data-grow</code> / <code>data-attached</code> attributes for the cluster
behaviours.
</p>
</section>
{/if}
{#if tab === 'sema'}
<section data-uix-section>
<h2 data-uix-section-title>
<span data-uix-layer-badge="sema">sema</span> · events
</h2>
<p data-uix-section-desc>
Group declares no semantic events. As a passive layout primitive, it does not commit,
emerge, or react to anything — it just arranges its children. The interactive elements
inside the group (buttons, toggles) own their own sema. ARIA grouping semantics
(<code>role="group"</code>, <code>role="toolbar"</code>, <code>role="radiogroup"</code>)
belong to the consumer who knows what kind of cluster this is.
</p>
</section>
{/if}
{#if tab === 'recipe'}
<section data-uix-section>
<h2 data-uix-section-title>Eidos recipe</h2>
<p data-uix-section-desc>
Recipe lives in <code>src/uix/eidos/components/group/group.css</code> and layers the
<code>grow</code> and <code>attached</code> behaviours on top of the Flex recipe.
</p>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Selector</th><th>Owner</th><th>Purpose</th></tr></thead>
<tbody>
<tr>
<td class="name"><code>[data-group]</code></td>
<td><span data-uix-tag data-kind="morfo">morfo</span></td>
<td>Provider marker.</td>
</tr>
<tr>
<td class="name"><code>[data-group][data-grow] &gt; *</code></td>
<td><span data-uix-tag data-kind="eidos">eidos</span></td>
<td>Apply <code>flex: 1 1 0</code> to every direct child.</td>
</tr>
<tr>
<td class="name"><code>[data-group][data-attached] &gt; *</code></td>
<td><span data-uix-tag data-kind="eidos">eidos</span></td>
<td>Squash inner radii and negative-margin overlap to absorb adjacent borders.</td>
</tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'a11y'}
<section data-uix-section>
<h2 data-uix-section-title>Accessibility</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Concern</th><th>Contract</th></tr></thead>
<tbody>
<tr><td class="name">Role</td><td>None implicit. Group is shape-agnostic — assign <code>role="group"</code>, <code>role="toolbar"</code> or <code>role="radiogroup"</code> on the Group provider via <code>{`{...rest}`}</code> when the cluster has semantic meaning. Reach for the <a href="/uix/components/toolbar">&lt;Toolbar&gt;</a> primitive for true toolbar semantics.</td></tr>
<tr><td class="name">Label</td><td>Provide <code>aria-label</code> or <code>aria-labelledby</code> on the Group when assigning a grouping role.</td></tr>
<tr><td class="name">Keyboard</td><td>Group itself is not focusable. Tab order follows DOM order. For arrow-key navigation between children use the headless toolbar / radio-group soma.</td></tr>
<tr><td class="name">Reduced motion</td><td>Group does not animate.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

@ -1,8 +1,91 @@
<script lang="ts">
import { Section, type SectionSize } from '$uix/eidos/components/section';
import { Section, type SectionProps, type SectionSize } from '$uix/eidos/components/section';
import { Box } from '$uix/eidos/components/box';
import { compileMorfo } from '$uix/morfo';
import { sectionMorfo } from '@/uix/morfo/components/section';
const sizes: SectionSize[] = ['sm', 'md', 'lg', 'xl'];
let size = $state<SectionSize>('lg');
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
type TraceEntry = { event: string; family: string; intent?: string; at: number };
let tab = $state<Tab>('live');
let trace = $state<TraceEntry[]>([]);
let stageRef = $state<HTMLElement | null>(null);
// ── Live state — Section props ────────────────────────────────────────
let size = $state<SectionSize>('md');
let paddingY = $state<string>('');
let paddingX = $state<number>(4);
const sizeOptions: readonly SectionSize[] = ['sm', 'md', 'lg', 'xl'];
const sectionProps = $derived<Partial<SectionProps>>({
size,
paddingY: paddingY || undefined,
paddingX
});
// ── Compiled morfo ────────────────────────────────────────────────────
const compiled = compileMorfo(sectionMorfo);
const partsList = $derived([...compiled.parts.byKebab.values()]);
const events = $derived([...compiled.actions.byName.values()]);
$effect(() => {
const el = stageRef;
if (!el) return;
const obs = new MutationObserver((mutations) => {
for (const m of mutations) {
if (m.attributeName !== 'data-event') continue;
const target = m.target as Element;
const ev = target.getAttribute('data-event');
if (!ev) continue;
trace = [
{
event: ev,
family: target.getAttribute('data-event-family') ?? '—',
intent: target.getAttribute('data-event-intent') ?? undefined,
at: Date.now()
},
...trace
].slice(0, 6);
}
});
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
return () => obs.disconnect();
});
// ── Code snippets ─────────────────────────────────────────────────────
const somaSnippet = $derived(
[
'<!-- Section is eidos-native — no soma layer. -->',
'<!-- Equivalent semantic markup (not real soma): -->',
'',
'<div',
' data-box',
' data-section',
` data-size="${size}"`,
` style="inline-size: 100%; padding-block: var(--section-padding-block-${size});"`,
'>',
' …',
'</div>'
].join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { Section } from '$uix/eidos/components/section';",
'</' + 'script>',
'',
'<Section',
size !== 'lg' && ` size="${size}"`,
paddingY && ` paddingY="${paddingY}"`,
paddingX > 0 && ` paddingX={${paddingX}}`,
'>',
' …',
'</Section>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
@ -10,88 +93,294 @@
<div data-uix-eyebrow>Layout · Section</div>
<h1 data-uix-page-title>Section</h1>
<p data-uix-page-lede>
Top-level page section with consistent block-axis padding scaled by
<code>size</code>.
Top-level page section with consistent block-axis padding. Four size tokens
(<code>sm · md · lg · xl</code>) map to <code>--section-padding-block-{`{size}`}</code>.
Despite the name, Section currently renders as <code>&lt;div&gt;</code> — there is no
<code>as</code> prop yet, so when you need a real <code>&lt;section&gt;</code> landmark,
wrap or nest one. For centred max-width content use
<a href="/uix/components/container">&lt;Container&gt;</a>; for non-semantic padding use
<a href="/uix/components/box">&lt;Box&gt;</a>.
</p>
<div data-uix-page-meta>
<span data-uix-meta-pill>
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>events</span>0
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>sizes</span>{sizeOptions.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>scope</span>eidos
</span>
</div>
</header>
<section>
<h2>Live example</h2>
<div style="display: flex; gap: 8px; margin-bottom: 12px">
{#each sizes as s (s)}
<label style="display: inline-flex; gap: 4px; align-items: center">
<input type="radio" name="size" value={s} bind:group={size} />
<span><code>{s}</code></span>
</label>
{/each}
</div>
<Section
{size}
style="background: var(--color-surface-1); border: 1px dashed var(--color-border); border-radius: 8px"
<!-- Live preview always rendered -->
<div data-uix-stage>
<div
data-uix-stage-area
bind:this={stageRef}
style="background: repeating-linear-gradient(0deg, transparent 0 8px, var(--color-surface-2) 8px 9px); inline-size: 100%;"
>
<p style="margin: 0; text-align: center">
Section content (size: <code>{size}</code>).
<Section
{...sectionProps}
style="border: 1px dashed var(--color-border-default); border-radius: var(--radius-md); background: var(--color-surface-1);"
>
<Box
padding={3}
style="border: 1px solid var(--color-affirm-border); border-radius: var(--radius-sm); background: var(--color-affirm-track); color: var(--color-affirm-text); text-align: center;"
>
Content (padding-block: var(--section-padding-block-{size}))
</Box>
</Section>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
<span>{trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`}</span>
<span style="color: var(--uix-text-faint)">·</span>
<span data-uix-stage-trace-key>size</span>
<span>{size}</span>
<span style="margin-inline-start: auto;">
<span data-uix-stage-trace-key>paddingY</span> {paddingY || `var(--section-padding-block-${size})`}
</span>
</div>
</div>
<div data-uix-tabs role="tablist">
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
API <span data-uix-tab-count>2</span>
</button>
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
<span data-uix-layer-badge="morfo">morfo</span>
<span data-uix-tab-count>{partsList.length}p · 0e</span>
</button>
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
<span data-uix-layer-badge="sema">sema</span>
<span data-uix-tab-count>{events.length}</span>
</button>
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
</div>
{#if tab === 'live'}
<section data-uix-section>
<h2 data-uix-section-title>Controls</h2>
<p data-uix-section-desc>
Section is eidos-native — no <span data-uix-layer-badge="soma">soma</span> split. The
horizontal hatched background shows how the block padding shifts content vertically
as <code>size</code> changes. Note the rendered element is a <code>&lt;div&gt;</code>
— see the A11y tab for guidance on adding a real landmark.
</p>
<div data-uix-subsection-head>
<span data-uix-layer-badge="eidos">eidos</span> props · padding
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>size <span data-uix-control-hint>→ var(--section-padding-block-N)</span></span>
<span data-uix-chips role="radiogroup">
{#each sizeOptions as opt}
<button data-uix-chip data-active={size === opt} onclick={() => (size = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>paddingY <span data-uix-control-hint>override size-keyed default</span></span>
<input
type="text"
placeholder="(size default)"
bind:value={paddingY}
style="inline-size: 12rem;"
/>
</label>
<label data-uix-control>
<span data-uix-control-label>paddingX <span data-uix-control-hint>inherited from Box</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={paddingX}
style="inline-size: 6rem;"
/>
</label>
</div>
<!-- ── Code snippets per layer ─────────────────────────────────── -->
<div data-uix-code>
<div data-uix-code-head>
<span data-uix-layer-badge="soma">soma</span>
<span>n/a · section is eidos-native — equivalent markup shown</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{somaSnippet}</code></pre>
</div>
<div data-uix-code style="margin-top: var(--uix-space-3);">
<div data-uix-code-head>
<span data-uix-layer-badge="eidos">eidos</span>
<span>visual · size-keyed block padding on top of Box</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{eidosSnippet}</code></pre>
</div>
</section>
{/if}
{#if tab === 'api'}
<section data-uix-section>
<h2 data-uix-section-title>API reference</h2>
<p data-uix-section-desc>
Section is a one-prop specialization of <a href="/uix/components/box"
><code>&lt;Box&gt;</code></a
>: it sets <code>width: 100%</code>, picks a default
<code>padding-block</code> from <code>size</code>, and renders as <code>&lt;div&gt;</code>.
If you pass <code>paddingY</code> directly, your value wins over the size-keyed
default.
</p>
<div data-uix-subsection-head>Padding</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">size</td><td class="type">sm | md | lg | xl</td><td class="default">'lg'</td><td>Maps to <code>--section-padding-block-{`{size}`}</code>: sm→8 / md→12 / lg→16 / xl→24 space steps.</td></tr>
<tr><td class="name">paddingY</td><td class="type">number | string</td><td class="default">SIZE_TO_PADDING[size]</td><td>Override the size-keyed default per-instance.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Inherited from Box</div>
<p data-uix-section-desc>
Every <a href="/uix/components/box">BoxProps</a> field is forwarded:
<code>padding*</code>, <code>margin*</code>, <code>width</code> (locked to 100% by
Section), <code>height</code>, <code>position</code>, <code>overflow*</code>. Pass
<code>paddingX</code> for horizontal padding (no default).
</p>
<div data-uix-subsection-head>Limitations</div>
<p data-uix-section-desc>
Section currently has no <code>as</code> prop — the rendered element is always
<code>&lt;div&gt;</code>. Add a <code>&lt;section&gt;</code> wrapper outside Section
(or nest a <code>&lt;section&gt;</code> as the first child) when landmark semantics
are needed.
</p>
</Section>
</section>
<section>
<h2>Padding scale</h2>
<table>
<thead>
<tr>
<th>Size</th>
<th>Block padding</th>
</tr>
</thead>
<tbody>
<tr><td><code>sm</code></td><td>var(--space-8) = 32px</td></tr>
<tr><td><code>md</code></td><td>var(--space-12) = 48px</td></tr>
<tr><td><code>lg</code></td><td>var(--space-16) = 64px</td></tr>
<tr><td><code>xl</code></td><td>calc(var(--space-16) * 1.5) = 96px</td></tr>
</tbody>
</table>
</section>
<section>
<h2>Props</h2>
<table>
<thead>
<tr>
<th>Prop</th>
<th>Default</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>size</code></td>
<td>'lg'</td>
<td>sm · md · lg · xl</td>
</tr>
<tr>
<td><code>paddingY</code></td>
<td>—</td>
<td>override the size-keyed default</td>
</tr>
<tr>
<td colspan="3"><em>… plus every <code>BoxProps</code> prop</em></td>
</tr>
</tbody>
</table>
</section>
<section>
<h2>Reference</h2>
<ul>
<li>
<strong>radix-themes Section</strong> — same intent (size-keyed block padding
for vertical rhythm).
</li>
<li>
<strong>HTML <code>&lt;section&gt;</code></strong> — Section is a `&lt;div&gt;`
in batch 1; wrap with a real <code>&lt;section&gt;</code> when you need landmark semantics.
</li>
</ul>
</section>
<div data-uix-subsection-head>Reference comparison</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Library</th><th>Closest equivalent</th><th>Difference</th></tr></thead>
<tbody>
<tr><td class="name">radix-themes</td><td><code>&lt;Section&gt;</code></td><td>Radix renders a real <code>&lt;section&gt;</code> by default and takes <code>size="1..4"</code>; UIX uses named tokens (<code>sm..xl</code>) and renders <code>&lt;div&gt;</code> pending an <code>as</code> prop.</td></tr>
<tr><td class="name">chakra-ui</td><td>n/a</td><td>Chakra has no dedicated Section — they recommend <code>&lt;Box as="section" py="…"&gt;</code>. UIX names the pattern as a primitive for consistency.</td></tr>
<tr><td class="name">mantine</td><td>n/a</td><td>Mantine has no Section either. Sections are usually authored ad-hoc with Stack + AppShell.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'morfo'}
<section data-uix-section>
<h2 data-uix-section-title>Morfo contract</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Field</th><th>Value</th></tr></thead>
<tbody>
<tr><td class="name">name</td><td>{sectionMorfo.name}</td></tr>
<tr><td class="name">kebab</td><td><code>{sectionMorfo.kebab}</code></td></tr>
<tr><td class="name">scope</td><td>{sectionMorfo.scope.join(', ')}</td></tr>
<tr><td class="name">parts</td><td>{partsList.length}</td></tr>
<tr><td class="name">events</td><td>0</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Parts</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>kebab</th><th>marker</th><th>element</th><th>archetype</th><th>optional</th></tr></thead>
<tbody>
{#each partsList as part}
<tr>
<td class="name">{part.kebab}</td>
<td><code data-uix-part-marker>[{part.marker}]</code></td>
<td class="type">&lt;{part.defaultElement}&gt;</td>
<td class="type">{part.archetype}</td>
<td class="default">{part.optional ? 'yes' : 'no'}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<p data-uix-section-desc style="margin-top: var(--uix-space-4);">
Section composes through <code>&lt;Box&gt;</code>, so the rendered DOM is a single
<code>div[data-box][data-section]</code> shell with a <code>data-size</code>
attribute. Recipe lives at
<code>src/uix/eidos/components/section/section.css</code> and declares the
<code>--section-padding-block-*</code> tokens locally.
</p>
</section>
{/if}
{#if tab === 'sema'}
<section data-uix-section>
<h2 data-uix-section-title>
<span data-uix-layer-badge="sema">sema</span> · events
</h2>
<p data-uix-section-desc>
Section declares no semantic events. As a passive layout primitive, it does not
commit, emerge, or react to anything — it just pads its children. Content inside the
section owns its own sema.
</p>
</section>
{/if}
{#if tab === 'recipe'}
<section data-uix-section>
<h2 data-uix-section-title>Eidos recipe</h2>
<p data-uix-section-desc>
Recipe lives in <code>src/uix/eidos/components/section/section.css</code>. The
<code>--section-padding-block-*</code> tokens are defined locally on the
<code>[data-section]</code> selector (intentionally not in the foundation — Section
is the sole consumer).
</p>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Selector</th><th>Owner</th><th>Purpose</th></tr></thead>
<tbody>
<tr>
<td class="name"><code>[data-section]</code></td>
<td><span data-uix-tag data-kind="morfo">morfo</span></td>
<td>Provider marker. Declares the per-size padding tokens and locks <code>inline-size: 100%</code>.</td>
</tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'a11y'}
<section data-uix-section>
<h2 data-uix-section-title>Accessibility</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Concern</th><th>Contract</th></tr></thead>
<tbody>
<tr><td class="name">Role</td><td>None implicit. Despite the name, Section renders as <code>&lt;div&gt;</code> — there is no implicit <code>region</code> role. Wrap Section in a real <code>&lt;section aria-labelledby="…"&gt;</code> or use a heading inside to provide landmark structure.</td></tr>
<tr><td class="name">Label</td><td>Not applicable to Section itself. If you wrap a real <code>&lt;section&gt;</code> around it, label it with <code>aria-labelledby</code> pointing at the heading.</td></tr>
<tr><td class="name">Keyboard</td><td>Section is not focusable. Tab order follows DOM order.</td></tr>
<tr><td class="name">Reduced motion</td><td>Section does not animate.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

@ -1,8 +1,109 @@
<script lang="ts">
import { Stack } from '$uix/eidos/components/stack';
import { Stack, type StackProps, type StackDirection } from '$uix/eidos/components/stack';
import { Box } from '$uix/eidos/components/box';
import { compileMorfo } from '$uix/morfo';
import { stackMorfo } from '@/uix/morfo/components/stack';
const cellStyle = 'background: var(--color-surface-2); border-radius: 4px; padding: 8px 12px';
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
type TraceEntry = { event: string; family: string; intent?: string; at: number };
let tab = $state<Tab>('live');
let trace = $state<TraceEntry[]>([]);
let stageRef = $state<HTMLElement | null>(null);
// ── Live state — Stack container props ────────────────────────────────
let direction = $state<StackDirection>('column');
let align = $state<'stretch' | 'start' | 'center' | 'end' | 'baseline'>('stretch');
let justify = $state<
'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch'
>('start');
let gap = $state<number>(3);
let padding = $state<number>(4);
const directionOptions = ['row', 'row-reverse', 'column', 'column-reverse'] as const;
const alignOptions = ['stretch', 'start', 'center', 'end', 'baseline'] as const;
const justifyOptions = [
'start',
'center',
'end',
'space-between',
'space-around',
'space-evenly',
'stretch'
] as const;
const stackProps = $derived<Partial<StackProps>>({
direction,
align,
justify,
gap,
padding
});
// ── Compiled morfo ────────────────────────────────────────────────────
const compiled = compileMorfo(stackMorfo);
const partsList = $derived([...compiled.parts.byKebab.values()]);
const events = $derived([...compiled.actions.byName.values()]);
$effect(() => {
const el = stageRef;
if (!el) return;
const obs = new MutationObserver((mutations) => {
for (const m of mutations) {
if (m.attributeName !== 'data-event') continue;
const target = m.target as Element;
const ev = target.getAttribute('data-event');
if (!ev) continue;
trace = [
{
event: ev,
family: target.getAttribute('data-event-family') ?? '—',
intent: target.getAttribute('data-event-intent') ?? undefined,
at: Date.now()
},
...trace
].slice(0, 6);
}
});
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
return () => obs.disconnect();
});
// ── Code snippets ─────────────────────────────────────────────────────
const somaSnippet = $derived(
[
'<!-- Stack is eidos-native — no soma layer. -->',
'<!-- Equivalent semantic markup (not real soma): -->',
'',
'<div',
' data-box',
' data-flex',
' data-stack',
' style="display: flex; flex-direction: column; gap: var(--space-3);"',
'>',
' …',
'</div>'
].join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { Stack } from '$uix/eidos/components/stack';",
'</' + 'script>',
'',
'<Stack',
direction !== 'column' && ` direction="${direction}"`,
align !== 'stretch' && ` align="${align}"`,
justify !== 'start' && ` justify="${justify}"`,
gap > 0 && ` gap={${gap}}`,
padding > 0 && ` padding={${padding}}`,
'>',
' …',
'</Stack>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
@ -10,83 +111,316 @@
<div data-uix-eyebrow>Layout · Stack</div>
<h1 data-uix-page-title>Stack</h1>
<p data-uix-page-lede>
Vertical (default) or horizontal stack. Thin alias over Flex with
<code>direction='column'</code>.
Direction-controlled flex stack — vertical by default, horizontal when
<code>direction="row"</code>. Thin specialization of
<a href="/uix/components/flex">&lt;Flex&gt;</a> with locked nowrap and 4 ergonomic props
(<code>direction</code>, <code>gap</code>, <code>align</code>, <code>justify</code>). For
row-only clusters with edge-to-edge behaviour use
<a href="/uix/components/group">&lt;Group&gt;</a>; for the full flex API (including
<code>wrap</code> and per-axis gaps) drop down to <code>&lt;Flex&gt;</code>.
</p>
<div data-uix-page-meta>
<span data-uix-meta-pill>
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>events</span>0
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>extends</span>Flex
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>scope</span>eidos
</span>
</div>
</header>
<section>
<h2>Vertical (default)</h2>
<Stack
gap={2}
padding={4}
style="background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: 8px"
>
<Box style={cellStyle}>Row 1</Box>
<Box style={cellStyle}>Row 2</Box>
<Box style={cellStyle}>Row 3</Box>
</Stack>
</section>
<section>
<h2>Horizontal</h2>
<Stack
direction="row"
gap={2}
padding={4}
align="center"
style="background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: 8px"
>
<Box style={cellStyle}>A</Box>
<Box style={cellStyle}>B</Box>
<Box style={cellStyle}>C</Box>
</Stack>
</section>
<section>
<h2>Props</h2>
<table>
<thead>
<tr>
<th>Prop</th>
<th>Default</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>direction</code></td>
<td>'column'</td>
<td>row · row-reverse · column · column-reverse</td>
</tr>
<tr>
<td><code>gap</code></td>
<td>—</td>
<td>maps to <code>var(--space-N)</code> when numeric</td>
</tr>
<tr>
<td><code>align</code> / <code>justify</code></td>
<td>—</td>
<td>inherited from Flex</td>
</tr>
<tr>
<td colspan="3"><em>… plus FlexProps minus <code>wrap</code>, <code>inline</code>, <code>rowGap</code>, <code>columnGap</code></em></td>
</tr>
</tbody>
</table>
</section>
<section>
<h2>Reference</h2>
<ul>
<li>
<strong>chakra-ui Stack / VStack / HStack</strong> — same intent; we collapse
the three into one component with a <code>direction</code> prop.
</li>
<li>
<strong>radix-themes Flex direction='column'</strong> — equivalent shape; Stack
is the named shortcut.
</li>
</ul>
</section>
<!-- Live preview always rendered -->
<div data-uix-stage>
<div data-uix-stage-area bind:this={stageRef}>
<Stack
{...stackProps}
style="border: 1px dashed var(--color-border-default); border-radius: var(--radius-md); min-block-size: 10rem; min-inline-size: 24rem;"
>
<Box
padding={2}
style="border: 1px solid var(--color-primary-border); border-radius: var(--radius-sm); background: var(--color-primary-track); color: var(--color-primary-text);"
>Row A</Box>
<Box
padding={2}
style="border: 1px solid var(--color-affirm-border); border-radius: var(--radius-sm); background: var(--color-affirm-track); color: var(--color-affirm-text);"
>Row B</Box>
<Box
padding={2}
style="border: 1px solid var(--color-risk-border); border-radius: var(--radius-sm); background: var(--color-risk-track); color: var(--color-risk-text);"
>Row C</Box>
</Stack>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
<span>{trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`}</span>
<span style="color: var(--uix-text-faint)">·</span>
<span data-uix-stage-trace-key>direction</span>
<span>{direction}</span>
<span style="margin-inline-start: auto;">
<span data-uix-stage-trace-key>gap</span> {gap} ·
<span data-uix-stage-trace-key>align</span> {align}
</span>
</div>
</div>
<div data-uix-tabs role="tablist">
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
API <span data-uix-tab-count>4</span>
</button>
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
<span data-uix-layer-badge="morfo">morfo</span>
<span data-uix-tab-count>{partsList.length}p · 0e</span>
</button>
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
<span data-uix-layer-badge="sema">sema</span>
<span data-uix-tab-count>{events.length}</span>
</button>
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
</div>
{#if tab === 'live'}
<section data-uix-section>
<h2 data-uix-section-title>Controls</h2>
<p data-uix-section-desc>
Stack is eidos-native — no <span data-uix-layer-badge="soma">soma</span> split. The
4 container props below pass through to the underlying <code>&lt;Flex&gt;</code>.
Stack also inherits every <a href="/uix/components/box">Box</a> prop (padding,
margin, size, position) via Flex composition.
</p>
<div data-uix-subsection-head>
<span data-uix-layer-badge="eidos">eidos</span> props · stack behaviour
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>direction</span>
<span data-uix-chips role="radiogroup">
{#each directionOptions as opt}
<button
data-uix-chip
data-active={direction === opt}
onclick={() => (direction = opt)}>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>align <span data-uix-control-hint>cross-axis</span></span>
<span data-uix-chips role="radiogroup">
{#each alignOptions as opt}
<button data-uix-chip data-active={align === opt} onclick={() => (align = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>justify <span data-uix-control-hint>main-axis</span></span>
<span data-uix-chips role="radiogroup">
{#each justifyOptions as opt}
<button data-uix-chip data-active={justify === opt} onclick={() => (justify = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>gap <span data-uix-control-hint>0–8 → var(--space-N)</span></span>
<input type="number" min="0" max="8" step="1" bind:value={gap} style="inline-size: 6rem;" />
</label>
<label data-uix-control>
<span data-uix-control-label>padding <span data-uix-control-hint>inherited from Box</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={padding}
style="inline-size: 6rem;"
/>
</label>
</div>
<!-- ── Code snippets per layer ─────────────────────────────────── -->
<div data-uix-code>
<div data-uix-code-head>
<span data-uix-layer-badge="soma">soma</span>
<span>n/a · stack is eidos-native — equivalent markup shown</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{somaSnippet}</code></pre>
</div>
<div data-uix-code style="margin-top: var(--uix-space-3);">
<div data-uix-code-head>
<span data-uix-layer-badge="eidos">eidos</span>
<span>visual · 4 ergonomic props on top of Flex</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{eidosSnippet}</code></pre>
</div>
</section>
{/if}
{#if tab === 'api'}
<section data-uix-section>
<h2 data-uix-section-title>API reference</h2>
<p data-uix-section-desc>
Stack is a thin, opinionated specialization of <a href="/uix/components/flex"
><code>&lt;Flex&gt;</code></a
>: it locks <code>wrap</code> to nowrap, defaults <code>direction</code> to
<code>column</code>, and exposes only the four most-used container props. Drop down to
<code>&lt;Flex&gt;</code> when you need <code>wrap</code>, <code>rowGap</code>,
<code>columnGap</code> or <code>inline</code>.
</p>
<div data-uix-subsection-head>Container props</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">direction</td><td class="type">row | row-reverse | column | column-reverse</td><td class="default">'column'</td><td><code>flex-direction</code>.</td></tr>
<tr><td class="name">gap</td><td class="type">number | string</td><td class="default empty">—</td><td>Number → <code>var(--space-N)</code>.</td></tr>
<tr><td class="name">align</td><td class="type">stretch | start | center | end | baseline | flex-start | flex-end</td><td class="default empty">—</td><td><code>align-items</code> — cross-axis.</td></tr>
<tr><td class="name">justify</td><td class="type">start | center | end | space-between | space-around | space-evenly | stretch | flex-start | flex-end</td><td class="default empty">—</td><td><code>justify-content</code> — main-axis.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Inherited from Box</div>
<p data-uix-section-desc>
Every <a href="/uix/components/box">BoxProps</a> field is forwarded through Flex:
<code>padding*</code>, <code>margin*</code>, <code>width</code>, <code>height</code>,
<code>position</code>, <code>top/right/bottom/left</code>, <code>overflow*</code>, plus
item-side props (<code>alignSelf</code>, <code>gridColumn</code>, …).
</p>
<div data-uix-subsection-head>Not on Stack (use Flex instead)</div>
<p data-uix-section-desc>
<code>wrap</code>, <code>inline</code>, <code>rowGap</code>, <code>columnGap</code> —
Stack intentionally omits these. Use <a href="/uix/components/flex"
><code>&lt;Flex&gt;</code></a
> when you need them.
</p>
<div data-uix-subsection-head>Reference comparison</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Library</th><th>Closest equivalent</th><th>Difference</th></tr></thead>
<tbody>
<tr><td class="name">radix-themes</td><td><code>&lt;Flex direction="column"&gt;</code></td><td>Radix doesn't ship a separate Stack — they use Flex with direction. UIX names the direction-locked variant for the most common case.</td></tr>
<tr><td class="name">chakra-ui</td><td><code>&lt;Stack&gt;</code> / <code>&lt;VStack&gt;</code> / <code>&lt;HStack&gt;</code></td><td>Chakra exposes three components (Stack/VStack/HStack). UIX collapses to a single Stack with a <code>direction</code> prop — <a href="/uix/components/group">&lt;Group&gt;</a> covers the row-cluster case.</td></tr>
<tr><td class="name">mantine</td><td><code>&lt;Stack&gt;</code> / <code>&lt;Group&gt;</code></td><td>Mantine has the same split: vertical Stack + horizontal Group. UIX matches Mantine here.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'morfo'}
<section data-uix-section>
<h2 data-uix-section-title>Morfo contract</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Field</th><th>Value</th></tr></thead>
<tbody>
<tr><td class="name">name</td><td>{stackMorfo.name}</td></tr>
<tr><td class="name">kebab</td><td><code>{stackMorfo.kebab}</code></td></tr>
<tr><td class="name">scope</td><td>{stackMorfo.scope.join(', ')}</td></tr>
<tr><td class="name">parts</td><td>{partsList.length}</td></tr>
<tr><td class="name">events</td><td>0</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Parts</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>kebab</th><th>marker</th><th>element</th><th>archetype</th><th>optional</th></tr></thead>
<tbody>
{#each partsList as part}
<tr>
<td class="name">{part.kebab}</td>
<td><code data-uix-part-marker>[{part.marker}]</code></td>
<td class="type">&lt;{part.defaultElement}&gt;</td>
<td class="type">{part.archetype}</td>
<td class="default">{part.optional ? 'yes' : 'no'}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<p data-uix-section-desc style="margin-top: var(--uix-space-4);">
Stack composes through <code>&lt;Flex&gt;</code> which composes through
<code>&lt;Box&gt;</code>, so the rendered DOM is a single
<code>div[data-box][data-flex][data-stack]</code> shell. Recipe lives at
<code>src/uix/eidos/components/stack/stack.css</code> — currently just the marker; all
behaviour comes from the Flex layer.
</p>
</section>
{/if}
{#if tab === 'sema'}
<section data-uix-section>
<h2 data-uix-section-title>
<span data-uix-layer-badge="sema">sema</span> · events
</h2>
<p data-uix-section-desc>
Stack declares no semantic events. As a passive layout primitive, it does not commit,
emerge, or react to anything — it just arranges its children. Components that animate
on appearance should compose Stack with an interactive primitive (popover, drawer,
collapsible) that owns the relevant sema verbs.
</p>
</section>
{/if}
{#if tab === 'recipe'}
<section data-uix-section>
<h2 data-uix-section-title>Eidos recipe</h2>
<p data-uix-section-desc>
Recipe lives in <code>src/uix/eidos/components/stack/stack.css</code> — currently
declaration-only (the <code>[data-stack]</code> marker exists so consumers can target
stacks specifically). All visual behaviour layers on top of the Flex recipe.
</p>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Selector</th><th>Owner</th><th>Purpose</th></tr></thead>
<tbody>
<tr>
<td class="name"><code>[data-stack]</code></td>
<td><span data-uix-tag data-kind="morfo">morfo</span></td>
<td>Provider marker. Used by consumers for targeting; behaviour inherited from Flex.</td>
</tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'a11y'}
<section data-uix-section>
<h2 data-uix-section-title>Accessibility</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Concern</th><th>Contract</th></tr></thead>
<tbody>
<tr><td class="name">Role</td><td>None implicit. Default element is <code>&lt;div&gt;</code> — semantically neutral. Wrap Stack in a landmark (<code>&lt;nav&gt;</code>, <code>&lt;section&gt;</code>, <code>&lt;ul role="list"&gt;</code>) when content needs one.</td></tr>
<tr><td class="name">Label</td><td>Not applicable — Stack has no content semantics. Labels belong to the interactive children.</td></tr>
<tr><td class="name">Keyboard</td><td>Stack is not focusable. Tab order follows DOM order even when <code>direction</code> visually reverses (<code>row-reverse</code> / <code>column-reverse</code>). Verify visual order matches focus order for keyboard users.</td></tr>
<tr><td class="name">Reduced motion</td><td>Stack does not animate.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

@ -1,21 +1,132 @@
<script lang="ts">
import { Wrap } from '$uix/eidos/components/wrap';
import { Wrap, type WrapProps } from '$uix/eidos/components/wrap';
import { Box } from '$uix/eidos/components/box';
import { compileMorfo } from '$uix/morfo';
import { wrapMorfo } from '@/uix/morfo/components/wrap';
const tagStyle =
'background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 999px; padding: 4px 10px; font-size: 0.875rem';
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
type TraceEntry = { event: string; family: string; intent?: string; at: number };
let tab = $state<Tab>('live');
let trace = $state<TraceEntry[]>([]);
let stageRef = $state<HTMLElement | null>(null);
const tags = [
'design',
'systems',
'reactive',
// ── Live state — Wrap container props ─────────────────────────────────
let gap = $state<number>(2);
let rowGap = $state<number>(0);
let columnGap = $state<number>(0);
let align = $state<'stretch' | 'start' | 'center' | 'end' | 'baseline'>('center');
let justify = $state<
'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch'
>('start');
let padding = $state<number>(4);
let itemCount = $state<number>(12);
const alignOptions = ['stretch', 'start', 'center', 'end', 'baseline'] as const;
const justifyOptions = [
'start',
'center',
'end',
'space-between',
'space-around',
'space-evenly',
'stretch'
] as const;
const wrapProps = $derived<Partial<WrapProps>>({
gap,
rowGap: rowGap || undefined,
columnGap: columnGap || undefined,
align,
justify,
padding
});
// ── Compiled morfo ────────────────────────────────────────────────────
const compiled = compileMorfo(wrapMorfo);
const partsList = $derived([...compiled.parts.byKebab.values()]);
const events = $derived([...compiled.actions.byName.values()]);
const pillLabels = [
'svelte',
'kit',
'vite',
'eslint',
'prettier',
'typescript',
'playwright',
'vitest',
'lucide',
'zod',
'tailwind',
'turbo',
'pnpm',
'storybook',
'css',
'tokens',
'accessibility',
'i18n',
'documentation'
'html'
];
const pills = $derived(pillLabels.slice(0, itemCount));
$effect(() => {
const el = stageRef;
if (!el) return;
const obs = new MutationObserver((mutations) => {
for (const m of mutations) {
if (m.attributeName !== 'data-event') continue;
const target = m.target as Element;
const ev = target.getAttribute('data-event');
if (!ev) continue;
trace = [
{
event: ev,
family: target.getAttribute('data-event-family') ?? '—',
intent: target.getAttribute('data-event-intent') ?? undefined,
at: Date.now()
},
...trace
].slice(0, 6);
}
});
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
return () => obs.disconnect();
});
// ── Code snippets ─────────────────────────────────────────────────────
const somaSnippet = $derived(
[
'<!-- Wrap is eidos-native — no soma layer. -->',
'<!-- Equivalent semantic markup (not real soma): -->',
'',
'<div',
' data-box',
' data-flex',
' data-wrap',
' style="display: flex; flex-wrap: wrap; gap: var(--space-2);"',
'>',
' …',
'</div>'
].join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { Wrap } from '$uix/eidos/components/wrap';",
'</' + 'script>',
'',
'<Wrap',
gap > 0 && ` gap={${gap}}`,
rowGap > 0 && ` rowGap={${rowGap}}`,
columnGap > 0 && ` columnGap={${columnGap}}`,
align !== 'stretch' && ` align="${align}"`,
justify !== 'start' && ` justify="${justify}"`,
padding > 0 && ` padding={${padding}}`,
'>',
' {#each tags as tag}<Tag>{tag}</Tag>{/each}',
'</Wrap>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
@ -23,59 +134,327 @@
<div data-uix-eyebrow>Layout · Wrap</div>
<h1 data-uix-page-title>Wrap</h1>
<p data-uix-page-lede>
Flex row that always wraps. Use for tag clouds, chip groups and any
row-of-children that should reflow on narrow viewports.
Flex row that <em>always</em> wraps. Use for tag/chip clusters, filter bars or anything
that should reflow across multiple lines on narrow viewports. Equivalent to
<a href="/uix/components/flex">&lt;Flex wrap="wrap"&gt;</a> with two extra ergonomic
gap-axis shorthands (<code>rowGap</code>, <code>columnGap</code>). For nowrap clusters
use <a href="/uix/components/group">&lt;Group&gt;</a>; for arbitrary flex direction use
<code>&lt;Flex&gt;</code>.
</p>
<div data-uix-page-meta>
<span data-uix-meta-pill>
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>events</span>0
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>extends</span>Flex
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>scope</span>eidos
</span>
</div>
</header>
<section>
<h2>Live example</h2>
<Wrap
gap={2}
padding={4}
style="background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: 8px; max-width: 360px"
>
{#each tags as t (t)}
<span style={tagStyle}>{t}</span>
{/each}
</Wrap>
</section>
<section>
<h2>Props</h2>
<table>
<thead>
<tr>
<th>Prop</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gap</code> / <code>rowGap</code> / <code>columnGap</code></td>
<td>independent row/column gaps</td>
</tr>
<tr>
<td><code>align</code> / <code>justify</code></td>
<td>main- and cross-axis alignment</td>
</tr>
<tr>
<td colspan="2"><em>… plus FlexProps minus <code>direction</code> and <code>wrap</code></em></td>
</tr>
</tbody>
</table>
</section>
<section>
<h2>Reference</h2>
<ul>
<li>
<strong>mantine Group wrap</strong> — same intent; we name the wrap-locked
variant explicitly to make intent obvious at the call site.
</li>
<li>
<strong>chakra-ui Wrap</strong> — origin of the dedicated wrap component.
</li>
</ul>
</section>
<!-- Live preview always rendered -->
<div data-uix-stage>
<div data-uix-stage-area bind:this={stageRef}>
<Wrap
{...wrapProps}
style="border: 1px dashed var(--color-border-default); border-radius: var(--radius-md); max-inline-size: 32rem; min-block-size: 8rem;"
>
{#each pills as label}
<Box
paddingX={3}
paddingY={1}
style="border: 1px solid var(--color-border-default); border-radius: 999px; background: var(--color-surface-2); font-size: 0.875rem;"
>{label}</Box>
{/each}
</Wrap>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
<span>{trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`}</span>
<span style="color: var(--uix-text-faint)">·</span>
<span data-uix-stage-trace-key>items</span>
<span>{pills.length}</span>
<span style="margin-inline-start: auto;">
<span data-uix-stage-trace-key>gap</span> {gap} ·
<span data-uix-stage-trace-key>justify</span> {justify}
</span>
</div>
</div>
<div data-uix-tabs role="tablist">
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
API <span data-uix-tab-count>5</span>
</button>
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
<span data-uix-layer-badge="morfo">morfo</span>
<span data-uix-tab-count>{partsList.length}p · 0e</span>
</button>
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
<span data-uix-layer-badge="sema">sema</span>
<span data-uix-tab-count>{events.length}</span>
</button>
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
</div>
{#if tab === 'live'}
<section data-uix-section>
<h2 data-uix-section-title>Controls</h2>
<p data-uix-section-desc>
Wrap is eidos-native — no <span data-uix-layer-badge="soma">soma</span> split. Locks
<code>flex-wrap: wrap</code> and exposes 5 container props on top of <code>&lt;Flex&gt;</code>.
The stage caps width at 32rem to demonstrate reflow.
</p>
<div data-uix-subsection-head>
<span data-uix-layer-badge="eidos">eidos</span> props · wrap behaviour
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>gap <span data-uix-control-hint>both axes</span></span>
<input type="number" min="0" max="8" step="1" bind:value={gap} style="inline-size: 6rem;" />
</label>
<label data-uix-control>
<span data-uix-control-label>rowGap <span data-uix-control-hint>between wrapped lines</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={rowGap}
style="inline-size: 6rem;"
/>
</label>
<label data-uix-control>
<span data-uix-control-label>columnGap <span data-uix-control-hint>between items in a line</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={columnGap}
style="inline-size: 6rem;"
/>
</label>
<label data-uix-control>
<span data-uix-control-label>align <span data-uix-control-hint>per-line cross-axis</span></span>
<span data-uix-chips role="radiogroup">
{#each alignOptions as opt}
<button data-uix-chip data-active={align === opt} onclick={() => (align = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>justify <span data-uix-control-hint>main-axis</span></span>
<span data-uix-chips role="radiogroup">
{#each justifyOptions as opt}
<button data-uix-chip data-active={justify === opt} onclick={() => (justify = opt)}
>{opt}</button
>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>padding <span data-uix-control-hint>inherited from Box</span></span>
<input
type="number"
min="0"
max="8"
step="1"
bind:value={padding}
style="inline-size: 6rem;"
/>
</label>
<label data-uix-control>
<span data-uix-control-label>items <span data-uix-control-hint>demo content count</span></span>
<input
type="number"
min="1"
max="16"
step="1"
bind:value={itemCount}
style="inline-size: 6rem;"
/>
</label>
</div>
<!-- ── Code snippets per layer ─────────────────────────────────── -->
<div data-uix-code>
<div data-uix-code-head>
<span data-uix-layer-badge="soma">soma</span>
<span>n/a · wrap is eidos-native — equivalent markup shown</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{somaSnippet}</code></pre>
</div>
<div data-uix-code style="margin-top: var(--uix-space-3);">
<div data-uix-code-head>
<span data-uix-layer-badge="eidos">eidos</span>
<span>visual · always wraps · per-axis gap shorthands</span>
<span data-uix-code-lang>svelte</span>
</div>
<pre><code>{eidosSnippet}</code></pre>
</div>
</section>
{/if}
{#if tab === 'api'}
<section data-uix-section>
<h2 data-uix-section-title>API reference</h2>
<p data-uix-section-desc>
Wrap is a narrow specialization of <a href="/uix/components/flex"
><code>&lt;Flex&gt;</code></a
>: locks <code>wrap</code> to <code>'wrap'</code>, drops <code>direction</code>
(always row), and elevates <code>rowGap</code> / <code>columnGap</code> as
first-class props because per-axis gaps are the typical reason to reach for Wrap.
</p>
<div data-uix-subsection-head>Container props</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
<tbody>
<tr><td class="name">gap</td><td class="type">number | string</td><td class="default empty">—</td><td>Shorthand for both axes. Number → <code>var(--space-N)</code>.</td></tr>
<tr><td class="name">rowGap</td><td class="type">number | string</td><td class="default empty">—</td><td>Gap between wrapped lines.</td></tr>
<tr><td class="name">columnGap</td><td class="type">number | string</td><td class="default empty">—</td><td>Gap between items within a line.</td></tr>
<tr><td class="name">align</td><td class="type">stretch | start | center | end | baseline | flex-start | flex-end</td><td class="default empty">—</td><td><code>align-items</code> per line — cross-axis.</td></tr>
<tr><td class="name">justify</td><td class="type">start | center | end | space-between | space-around | space-evenly | stretch | flex-start | flex-end</td><td class="default empty">—</td><td><code>justify-content</code> — main-axis.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Inherited from Box</div>
<p data-uix-section-desc>
Every <a href="/uix/components/box">BoxProps</a> field is forwarded through Flex:
<code>padding*</code>, <code>margin*</code>, <code>width</code>, <code>height</code>,
<code>position</code>, <code>overflow*</code>, plus item-side props.
</p>
<div data-uix-subsection-head>Not on Wrap (use Flex instead)</div>
<p data-uix-section-desc>
<code>direction</code> (Wrap is always row), <code>wrap</code> (locked to wrap),
<code>inline</code> — Wrap intentionally omits these. Use <a
href="/uix/components/flex"><code>&lt;Flex&gt;</code></a
> when you need them.
</p>
<div data-uix-subsection-head>Reference comparison</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Library</th><th>Closest equivalent</th><th>Difference</th></tr></thead>
<tbody>
<tr><td class="name">radix-themes</td><td><code>&lt;Flex wrap="wrap"&gt;</code></td><td>Radix doesn't ship a separate Wrap — they recommend Flex with the <code>wrap</code> prop. UIX names it for the common chip-cluster case.</td></tr>
<tr><td class="name">chakra-ui</td><td><code>&lt;Wrap&gt;</code> / <code>&lt;WrapItem&gt;</code></td><td>Chakra wraps each child in a <code>&lt;WrapItem&gt;</code> internally. UIX has no item wrapper — gap is owned by the container.</td></tr>
<tr><td class="name">mantine</td><td><code>&lt;Group wrap="wrap"&gt;</code></td><td>Mantine collapses both into Group with a prop. UIX splits Group (nowrap) and Wrap (wrap) because their visual intent is different.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'morfo'}
<section data-uix-section>
<h2 data-uix-section-title>Morfo contract</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Field</th><th>Value</th></tr></thead>
<tbody>
<tr><td class="name">name</td><td>{wrapMorfo.name}</td></tr>
<tr><td class="name">kebab</td><td><code>{wrapMorfo.kebab}</code></td></tr>
<tr><td class="name">scope</td><td>{wrapMorfo.scope.join(', ')}</td></tr>
<tr><td class="name">parts</td><td>{partsList.length}</td></tr>
<tr><td class="name">events</td><td>0</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Parts</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>kebab</th><th>marker</th><th>element</th><th>archetype</th><th>optional</th></tr></thead>
<tbody>
{#each partsList as part}
<tr>
<td class="name">{part.kebab}</td>
<td><code data-uix-part-marker>[{part.marker}]</code></td>
<td class="type">&lt;{part.defaultElement}&gt;</td>
<td class="type">{part.archetype}</td>
<td class="default">{part.optional ? 'yes' : 'no'}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<p data-uix-section-desc style="margin-top: var(--uix-space-4);">
Wrap composes through <code>&lt;Flex wrap="wrap"&gt;</code> which composes through
<code>&lt;Box&gt;</code>, so the rendered DOM is a single
<code>div[data-box][data-flex][data-wrap]</code> shell.
</p>
</section>
{/if}
{#if tab === 'sema'}
<section data-uix-section>
<h2 data-uix-section-title>
<span data-uix-layer-badge="sema">sema</span> · events
</h2>
<p data-uix-section-desc>
Wrap declares no semantic events. As a passive layout primitive, it does not commit,
emerge, or react to anything — it just arranges its children. Tags/chips/buttons
inside the Wrap own their own sema.
</p>
</section>
{/if}
{#if tab === 'recipe'}
<section data-uix-section>
<h2 data-uix-section-title>Eidos recipe</h2>
<p data-uix-section-desc>
Recipe lives in <code>src/uix/eidos/components/wrap/wrap.css</code>. The
<code>data-wrap</code> marker is mostly for consumer targeting; the actual
<code>flex-wrap: wrap</code> behaviour is set by the underlying Flex layer because Wrap
renders as <code>&lt;Flex wrap="wrap"&gt;</code>.
</p>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Selector</th><th>Owner</th><th>Purpose</th></tr></thead>
<tbody>
<tr>
<td class="name"><code>[data-wrap]</code></td>
<td><span data-uix-tag data-kind="morfo">morfo</span></td>
<td>Provider marker. Used by consumers for targeting; <code>flex-wrap</code> comes from the Flex layer.</td>
</tr>
</tbody>
</table>
</div>
</section>
{/if}
{#if tab === 'a11y'}
<section data-uix-section>
<h2 data-uix-section-title>Accessibility</h2>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Concern</th><th>Contract</th></tr></thead>
<tbody>
<tr><td class="name">Role</td><td>None implicit. Default element is <code>&lt;div&gt;</code>. When wrapping a list of tags/filters, consider <code>role="list"</code> + <code>role="listitem"</code> on the children for screen-reader semantics.</td></tr>
<tr><td class="name">Label</td><td>Not applicable — Wrap has no content semantics.</td></tr>
<tr><td class="name">Keyboard</td><td>Wrap is not focusable. Tab order follows DOM order; wrapped lines do not change the focus sequence. For arrow-key cluster navigation use a tag-group or toolbar soma.</td></tr>
<tr><td class="name">Reduced motion</td><td>Wrap does not animate. Reflow on resize follows CSS defaults.</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

Loading…
Cancel
Save

Powered by TurnKey Linux.