the kit

Kit components

25 components you copy into your project and own, in the spirit of shadcn: no package, no new tags, every color a token. Each picture is tuimark play on the component’s own document in kit/components, with its sample data, in the kit’s dark or light theme to match this site. The kit guide explains the conventions and the host helpers.

1 copy the kit

kit.tui holds a template per component and the overlays’ keys, and loads theme.tcss (the dark and light tokens) and kit.tcss (the k- classes) from its own folder. Keep the three files together.

git clone --depth 1 https://github.com/abdul-hamid-achik/tuimark
mkdir -p my-app/kit
cp tuimark/kit/kit.tui tuimark/kit/theme.tcss tuimark/kit/kit.tcss my-app/kit/
2 include it, then use a component

Include the kit first and your own sheet after it, so a token you re-declare rebrands the whole kit. Use a template with <use>, passing literal text as props, your data with with, a body as the content between <use> and </use>, and a variant with class; a class component’s markup is below, to copy. Each one’s contract says which props, store paths, actions, and keys it takes.

<tui theme="auto">
  <include src="kit/kit.tui"/>  <!-- the kit: sheets, keys, templates -->
  <style src="app.tcss"/>       <!-- yours, after it: token overrides -->
  <screen id="main">
    …
    <use template="k-alert" class="warn" title="Quota" icon="!" text="92% of the build minutes used."/>
  </screen>
</tui>

Layout

app bark-appbar

a one-row bar docked to the top

$ tuimark play kit/components/appbar.tui --data kit/components/appbar.sample.json --cols 72 --rows 472×4
an app bar: the product mark and name, the page title, the signed-in user and an environment badge on one rowan app bar: the product mark and name, the page title, the signed-in user and an environment badge on one row
takes
props brand, title, style; slot: the right side; reads app.user, app.env
needs
k-badge
Template: k-appbar in kit.tui
kit/kit.tui
<!-- k-appbar: a one-row bar docked to the top. Props: brand, title, style.
     Slot: the right side (meta text, badges). -->
<template id="k-appbar" props="brand title style">
  <row class="k-appbar" style="{$style}">
    <text class="k-appbar-brand">{$brand}</text>
    <text class="k-appbar-title">{$title}</text>
    <spacer/>
    <slot/>
  </row>
</template>
In use: components/appbar.tui
kit/components/appbar.tui
<!-- k-appbar · Contract: props brand, title, style; slot: the right side; reads app.user, app.env · Actions: none · Keys: none · Requires: k-badge -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <col id="app" width="1fr" height="1fr">
      <!-- COPY: the app bar is one row docked to the top of its parent, so
           the content below keeps all the remaining space. What you write
           inside the use goes on the right. Put at most one top-docked bar
           in a container. A page title from data is the class markup:
           <row class="k-appbar"> with its own k-appbar-* texts. -->
      <use template="k-appbar" brand="◆ orbit" title="Deployments">
        <text class="k-appbar-meta">{app.user}</text>
        <text class="k-badge ok">{app.env}</text>
      </use>
      <col width="1fr" height="1fr" pad="1">
        <text class="k-muted">The page content goes here.</text>
      </col>
    </col>
  </screen>
</tui>

status bark-statusbar

a one-row bar docked to the bottom, with filled segments

$ tuimark play kit/components/statusbar.tui --data kit/components/statusbar.sample.json --cols 72 --rows 672×6
a status bar docked at the bottom: the mode, the file, a synced mark and the cursor positiona status bar docked at the bottom: the mode, the file, a synced mark and the cursor position
takes
reads status.mode, status.file, status.synced, status.position
needs
k-muted
Markup: components/statusbar.tui
kit/components/statusbar.tui
<!-- k-statusbar · Contract: reads status.mode, status.file, status.synced, status.position · Actions: none · Keys: none · Requires: k-muted -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <col id="app" width="1fr" height="1fr">
      <col width="1fr" height="1fr" pad="1">
        <text class="k-muted">The page content goes here.</text>
      </col>
      <!-- COPY: the status bar is a one-row `row` with class `k-statusbar`,
           docked to the bottom of its parent. Left segments first, a
           `spacer`, then right segments. `k-statusbar-seg` is a filled chip
           (modifiers: ok, warn, danger); `k-statusbar-text` and
           `k-statusbar-muted` are plain. Only one bottom-docked bar per
           container (L005): put the key hints above it, not docked. -->
      <row class="k-statusbar">
        <text class="k-statusbar-seg">{status.mode}</text>
        <text class="k-statusbar-text">{status.file}</text>
        <spacer/>
        <text class="k-statusbar-seg ok" if="status.synced">synced</text>
        <text class="k-statusbar-seg warn" if="!status.synced">unsynced</text>
        <text class="k-statusbar-muted">{status.position}</text>
      </row>
    </col>
  </screen>
</tui>

tabsk-tabs

a tab strip bound to a path

$ tuimark play kit/components/tabs.tui --data kit/components/tabs.sample.json --cols 72 --rows 872×8
a tab strip with the active tab marked and a count in a tab label, above the active tab’s panela tab strip with the active tab marked and a count in a tab label, above the active tab’s panel
takes
reads and writes view (the active tab's id); reads tabs.overview, tabs.activity, tabs.settings, tabs.count
actions
none (the keymap uses the built-ins move-next, move-prev, switch-to)
keys
] and [ move, 1 to 3 switch
needs
k-card, k-hints
Markup: components/tabs.tui
kit/components/tabs.tui
<!-- k-tabs · Contract: reads and writes view (the active tab's id); reads tabs.overview, tabs.activity, tabs.settings, tabs.count · Actions: none (the keymap uses the built-ins move-next, move-prev, switch-to) · Keys: ] and [ move, 1 to 3 switch · Requires: k-card, k-hints -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <keymap>
    <bind keys="]" action="move-next" to="#nav" keycap="]/[" label="tab"/>
    <bind keys="[" action="move-prev" to="#nav"/>
    <bind keys="1" action="switch-to" to="#overview"/>
    <bind keys="2" action="switch-to" to="#activity"/>
    <bind keys="3" action="switch-to" to="#settings"/>
  </keymap>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="0">
      <!-- COPY: tabs are a `tabs` with class `k-tabs` bound to a path that
           holds the active tab's id (the host or `switch-to` writes it).
           Write `focusable` on it: whether a tab strip takes focus is then
           your choice, not a default. Each `tab` needs an `id` (yours, not
           a kit part: it is the value of the bound path) and a `label`;
           `short` is the label used when the strip does not fit. The
           generated labels are styled by the class (`.k-tabs > .tab-label`).
           Only the active tab's content is laid out. `mark` is the glyph
           before the active label. -->
      <tabs id="nav" class="k-tabs" bind="view" mark="▸" focusable="true">
        <tab id="overview" label="1 overview" short="1 ovr">
          <box class="k-card" title="Overview">
            <text class="k-card-text">{tabs.overview}</text>
          </box>
        </tab>
        <tab id="activity" label="2 activity ({tabs.count})" short="2 act">
          <box class="k-card" title="Activity">
            <text class="k-card-text">{tabs.activity}</text>
          </box>
        </tab>
        <tab id="settings" label="3 settings" short="3 set">
          <box class="k-card" title="Settings">
            <text class="k-card-text">{tabs.settings}</text>
          </box>
        </tab>
      </tabs>
      <hints class="k-hints"/>
    </col>
  </screen>
</tui>

split panek-split

a list beside a detail card, stacked on a narrow terminal

$ tuimark play kit/components/split.tui --data kit/components/split.sample.json --cols 72 --rows 1072×10
a list of incidents beside a detail pane that shows the selected onea list of incidents beside a detail pane that shows the selected one
takes
reads items[] {id, title, age}, detail.{title, status, open, age, summary, owner} (the host keeps detail with a Derive over items and the cursor); reads and writes cur (the cursor row's id)
actions
menu_select
keys
j and k move
needs
k-menu, k-card, k-badge, k-muted
Markup: components/split.tui
kit/components/split.tui
<!-- k-split · Contract: reads items[] {id, title, age}, detail.{title, status, open, age, summary, owner} (the host keeps detail with a Derive over items and the cursor); reads and writes cur (the cursor row's id) · Actions: menu_select · Keys: j and k move · Requires: k-menu, k-card, k-badge, k-muted -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <keymap when="#items">
    <bind keys="j" action="move-next"/>
    <bind keys="k" action="move-prev"/>
  </keymap>
  <screen id="demo" focus="#items">
    <!-- COPY: master / detail is a `row` with class `k-split`: a list on the
         left (`k-split-master`, 34% wide, 24 to 40 columns) and a card on
         the right (`k-split-detail`, the rest). The list `bind` is the
         selected id; the host keeps `detail` (a Derive over `items` and the
         cursor) so the right side follows the cursor with no handler.
         The detail card shows the badge for the status through class:NAME
         guards. -->
    <row class="k-split">
      <list id="items" class="k-menu k-split-master" each="items as it" key="it.id" bind="cur" title="Incidents" on:select="menu_select">
        <item>
          <row class="k-menu-row">
            <text class="k-menu-label">{it.title}</text>
            <text class="k-menu-key">{it.age}</text>
          </row>
        </item>
      </list>
      <box class="k-card k-split-detail" title="{detail.title}">
        <row width="1fr" height="1" gap="1">
          <text class="k-badge" class:danger="detail.open" class:ok="!detail.open">{detail.status}</text>
          <text class="k-muted">{detail.age} ago</text>
        </row>
        <text class="k-card-text" wrap="wrap">{detail.summary}</text>
        <text class="k-card-muted">owner: {detail.owner}</text>
      </box>
    </row>
  </screen>
</tui>

key hintsk-hints

the keymap’s labeled rows as a row of hints

$ tuimark play kit/components/hints.tui --cols 72 --rows 672×6
key hints generated from the keymap along the bottom rowkey hints generated from the keymap along the bottom row
takes
reads nothing from the store; shows the keymap rows that have a label
actions
none of its own (the demo names item_new, item_open, item_next, item_prev, item_search)
keys
whatever the keymap binds
needs
k-muted
Markup: components/hints.tui
kit/components/hints.tui
<!-- k-hints · Contract: reads nothing from the store; shows the keymap rows that have a label · Actions: none of its own (the demo names item_new, item_open, item_next, item_prev, item_search) · Keys: whatever the keymap binds · Requires: k-muted -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <!-- COPY: every keymap row with a `label` becomes a hint. `keycap` is the
       text shown instead of the key (use it for "j/k" or "^S"). A row
       without a label is bound but not shown. -->
  <keymap>
    <bind keys="n" action="item_new" label="new"/>
    <bind keys="enter" action="item_open" label="open"/>
    <bind keys="j" action="item_next" keycap="j/k" label="move"/>
    <bind keys="k" action="item_prev"/>
    <bind keys="/" action="item_search" label="search"/>
    <bind keys="q" action="quit" label="quit"/>
  </keymap>
  <screen id="demo">
    <col id="app" width="1fr" height="1fr">
      <col width="1fr" height="1fr" pad="1">
        <text class="k-muted">The page content goes here.</text>
      </col>
      <!-- COPY: `<hints/>` with class `k-hints`: one row, the key in the
           accent color (`.hint-key`), the label muted (`.hint-label`; the
           class styles both). Hints that do not fit are dropped from the
           right. `scope="active"` (the default) shows only the keys that
           would fire right now. -->
      <hints class="k-hints"/>
    </col>
  </screen>
</tui>

Content

cardk-card

a bordered panel with a title that takes the focus color while it holds focus

$ tuimark play kit/components/card.tui --data kit/components/card.sample.json --cols 72 --rows 1372×13
a titled card with a heading, a line of text and two buttons, and two smaller cards side by sidea titled card with a heading, a line of text and two buttons, and two smaller cards side by side
takes
props title, style; slot: the body; reads card.heading, card.text
actions
card_open, card_dismiss (the demo's buttons)
keys
tab, enter
needs
k-btn, k-title
Template: k-card in kit.tui
kit/kit.tui
<!-- k-card: a titled panel. Props: title, style. Slot: the body. A card
     whose title comes from data is the class markup,
     <box class="k-card" title="{PATH}">. -->
<template id="k-card" props="title style">
  <box class="k-card" title="{$title}" style="{$style}">
    <slot/>
  </box>
</template>
In use: components/card.tui
kit/components/card.tui
<!-- k-card · Contract: props title, style; slot: the body; reads card.heading, card.text · Actions: card_open, card_dismiss (the demo's buttons) · Keys: tab, enter · Requires: k-btn, k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo" focus="#card__open">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">card / panel</text>
      <!-- COPY: a card is a titled box; what you write inside the use is its
           body, with your own paths, ids and actions. The border turns to
           the focus color while anything inside holds focus. It wraps its
           content; style="height: 10" (or 1fr) fixes it. A title from data
           is the class markup: <box class="k-card" title="{PATH}">. -->
      <use template="k-card" title="Deploy">
        <text class="k-card-title">{card.heading}</text>
        <text class="k-card-muted">{card.text}</text>
        <row class="k-card-actions">
          <button id="card__open" class="k-btn primary" label="Open" on:click="card_open"/>
          <button id="card__dismiss" class="k-btn ghost" label="Dismiss" on:click="card_dismiss"/>
        </row>
      </use>
      <!-- COPY: side-by-side cards share the row; each takes `1fr`. -->
      <row width="1fr" height="auto" gap="1">
        <use template="k-card" title="Left">
          <text class="k-card-text">First card</text>
        </use>
        <use template="k-card" title="Right">
          <text class="k-card-text">Second card</text>
        </use>
      </row>
    </col>
  </screen>
</tui>

key / valuek-kv

a muted label and a value on one row, for a card of facts

$ tuimark play kit/components/kv.tui --data kit/components/kv.sample.json --cols 72 --rows 1072×10
a card titled Service with four rows, each a muted label and its value: name, owner, region and versiona card titled Service with four rows, each a muted label and its value: name, owner, region and version
takes
props label, style; with="PATH as v" reads v, the value
needs
k-card, k-title
Template: k-kv in kit.tui
kit/kit.tui
<!-- k-kv: one key / value row, in a card. Props: label, style.
     with="PATH as v": the value. -->
<template id="k-kv" props="label style">
  <row class="k-kv" style="{$style}">
    <text class="k-kv-label">{$label}</text>
    <text class="k-kv-value">{v}</text>
  </row>
</template>
In use: components/kv.tui
kit/components/kv.tui
<!-- k-kv · Contract: props label, style; with="PATH as v" reads v, the value · Actions: none · Keys: none · Requires: k-card, k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">key / value</text>
      <!-- COPY: one row per field, in a card: the label is literal, the
           value is a path. The label column is 8 wide; a sheet rule
           (.k-kv-label { width: 10; }) widens it for every row. -->
      <use template="k-card" title="Service">
        <use template="k-kv" label="Name" with="svc.name as v"/>
        <use template="k-kv" label="Owner" with="svc.owner as v"/>
        <use template="k-kv" label="Region" with="svc.region as v"/>
        <use template="k-kv" label="Version" with="svc.version as v"/>
      </use>
    </col>
  </screen>
</tui>

alertk-alert

a callout with an icon, in four status colors

$ tuimark play kit/components/alert.tui --data kit/components/alert.sample.json --cols 72 --rows 1672×16
four alerts, info, success, warning and danger, each a titled frame with an icon and a messagefour alerts, info, success, warning and danger, each a titled frame with an icon and a message
takes
props title, icon, text (each optional) and style; slot: more body, after the text; reads build.retry
needs
k-title
Template: k-alert in kit.tui
kit/kit.tui
<!-- k-alert: a callout. Props: title, icon, text, style. Slot: more body,
     after the text (a dynamic line, a button). Variant: info, ok, warn,
     danger. -->
<template id="k-alert" props="title icon text style">
  <box class="k-alert" title="{$title}" style="{$style}">
    <row class="k-alert-row">
      <text class="k-alert-icon">{$icon}</text>
      <col class="k-alert-body">
        <text class="k-alert-text">{$text}</text>
        <slot/>
      </col>
    </row>
  </box>
</template>
In use: components/alert.tui
kit/components/alert.tui
<!-- k-alert · Contract: props title, icon, text (each optional) and style; slot: more body, after the text; reads build.retry · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="0" pad="1">
      <text class="k-title">alert / callout</text>
      <!-- USE: one <use> of the k-alert template per alert, with its
           variant as the use's class (info, ok, warn, danger) and its text
           as props (title, icon, text; each optional). The title is the box
           title; the text wraps; the variant colors the frame and the icon.
           What you write inside the <use> (the last alert) is more body,
           after the text, with the paths of this document. -->
      <use template="k-alert" class="info" title="Heads up" icon="i" text="Deploys are paused until 09:00 UTC."/>
      <use template="k-alert" class="ok" title="Saved" icon="✓" text="Your changes are live in every region."/>
      <use template="k-alert" class="warn" title="Quota" icon="!" text="You have used 92% of this month's build minutes."/>
      <use template="k-alert" class="danger" title="Build failed" icon="✗" text="Step 3 exited with code 1: tests failed in pkg/router.">
        <text>{build.retry}</text>
      </use>
    </col>
  </screen>
</tui>

badgek-badge

a short status label, with a modifier for its color

$ tuimark play kit/components/badge.tui --data kit/components/badge.sample.json --cols 72 --rows 972×9
badges for states such as draft, new, passing, flaky and failed, and a build numberbadges for states such as draft, new, passing, flaky and failed, and a build number
takes
reads build.number, build.status, build.ok
needs
k-title
Markup: components/badge.tui
kit/components/badge.tui
<!-- k-badge · Contract: reads build.number, build.status, build.ok · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
  <!-- The kit: its sheets, its overlay keys and its templates. Your own
       sheet, if any, comes after it. -->
  <include src="../kit.tui"/>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">badge</text>
      <!-- COPY: a badge is one text with two classes: `k-badge` and a
           modifier. Modifiers: accent, ok, warn, danger, info (none =
           neutral). The label is literal text or a {path}. -->
      <row width="1fr" height="1" gap="1">
        <text class="k-badge">draft</text>
        <text class="k-badge accent">new</text>
        <text class="k-badge ok">passing</text>
      </row>
      <row width="1fr" height="1" gap="1">
        <text class="k-badge warn">flaky</text>
        <text class="k-badge danger">failed</text>
        <text class="k-badge info">{build.number}</text>
      </row>
      <!-- COPY: choose the modifier from data with class:NAME guards on the
           same node (the guards are paths the host keeps true or false). -->
      <row width="1fr" height="1" gap="1">
        <text class="k-badge" class:ok="build.ok" class:danger="!build.ok">{build.status}</text>
      </row>
    </col>
  </screen>
</tui>

statk-stat

a KPI card with a change and a sparkline

$ tuimark play kit/components/stat.tui --data kit/components/stat.sample.json --cols 72 --rows 872×8
two KPI cards, each with a value, a change marked up or down, and a sparklinetwo KPI cards, each with a value, a change marked up or down, and a sparkline
takes
props title, min, max (the sparkline range), style; with="PATH as s" reads s.value, s.delta, s.hist[] (numbers), and the flags s.good and s.bad
needs
k-title
Template: k-stat in kit.tui
kit/kit.tui
<!-- k-stat: a KPI card. Props: title, min, max (the sparkline's range),
     style. with="PATH as s": s.value, s.delta, s.hist (numbers); flags
     s.good and s.bad color the change. -->
<template id="k-stat" props="title min max style">
  <box class="k-stat" title="{$title}" style="{$style}">
    <text class="k-stat-value">{s.value}</text>
    <row class="k-stat-row">
      <text class="k-stat-delta" class:good="s.good" class:bad="s.bad">{s.delta}</text>
      <sparkline class="k-stat-spark" bind="s.hist" min="{$min}" max="{$max}"/>
    </row>
  </box>
</template>
In use: components/stat.tui
kit/components/stat.tui
<!-- k-stat · Contract: props title, min, max (the sparkline range), style; with="PATH as s" reads s.value, s.delta, s.hist[] (numbers), and the flags s.good and s.bad · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">stat / KPI card</text>
      <!-- USE: the k-stat template: the `title` prop as the box title, the
           value in bold, and a row with the change and a sparkline of s.hist. The
           flags s.good and s.bad turn the change green or red (whether a
           rise is good depends on the metric, so the host decides). `min`
           and `max` fix the sparkline's range (without them it comes from
           the values). Put
           stats in a row; each takes `1fr` of the width. -->
      <row width="1fr" height="auto" gap="1">
        <use template="k-stat" title="Requests" with="stats.req as s"/>
        <use template="k-stat" title="Errors" min="0" with="stats.err as s"/>
      </row>
    </col>
  </screen>
</tui>

labeled progressk-meter

a label, a value and a bar in eighths

$ tuimark play kit/components/meter.tui --data kit/components/meter.sample.json --cols 72 --rows 1272×12
three labeled progress bars with their values: an upload, disk use and teststhree labeled progress bars with their values: an upload, disk use and tests
takes
props label, style; with="PATH as m" reads m.text, m.pct (0 to 100), and the flags m.ok, m.warn and m.danger
needs
k-title
Template: k-meter in kit.tui
kit/kit.tui
<!-- k-meter: a labeled progress bar. Props: label, style. with="PATH as m":
     m.text, m.pct (0 to 100); flags m.ok, m.warn, m.danger. Variant: ok,
     warn, danger. -->
<template id="k-meter" props="label style">
  <col class="k-meter" style="{$style}">
    <row class="k-meter-head">
      <text class="k-meter-label">{$label}</text>
      <spacer/>
      <text class="k-meter-value">{m.text}</text>
    </row>
    <progress class="k-meter-bar" class:ok="m.ok" class:warn="m.warn" class:danger="m.danger" bind="m.pct"/>
  </col>
</template>
In use: components/meter.tui
kit/components/meter.tui
<!-- k-meter · Contract: props label, style; with="PATH as m" reads m.text, m.pct (0 to 100), and the flags m.ok, m.warn and m.danger · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">labeled progress</text>
      <!-- USE: the k-meter template: a head row (the label on the left, the
           value text on the right) over a progress bar of m.pct, a number
           from 0 to 100. Color the bar with a variant on the use (ok, warn,
           danger), or from data with the flags m.ok, m.warn and m.danger.
           The host updates the number (and the text) as the work
           advances. -->
      <use template="k-meter" label="Uploading artifact.tar" with="meters.upload as m"/>
      <use template="k-meter" label="Disk" with="meters.disk as m"/>
      <use template="k-meter" class="ok" label="Tests" with="meters.tests as m"/>
    </col>
  </screen>
</tui>

empty statek-empty

an icon, a title, a line of help and a call to action, centered

$ tuimark play kit/components/empty.tui --cols 72 --rows 1572×15
an empty state: an icon, a title, a line of text and a button, centeredan empty state: an icon, a title, a line of text and a button, centered
takes
props icon, title, text (icon and text optional); slot: the call to action, your button and your action
actions
deploy_create (the demo's button)
keys
enter on the button
needs
k-btn, k-title
Template: k-empty in kit.tui
kit/kit.tui
<!-- k-empty: an empty state, centered in the space left. Props: icon,
     title, text, style. Slot: the call to action (your button, your
     action). -->
<template id="k-empty" props="icon title text style">
  <col class="k-empty" style="{$style}">
    <text class="k-empty-icon">{$icon}</text>
    <text class="k-empty-title">{$title}</text>
    <text class="k-empty-text">{$text}</text>
    <slot/>
  </col>
</template>
In use: components/empty.tui
kit/components/empty.tui
<!-- k-empty · Contract: props icon, title, text (icon and text optional); slot: the call to action, your button and your action · Actions: deploy_create (the demo's button) · Keys: enter on the button · Requires: k-btn, k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo" focus="#deploy__create">
    <col width="1fr" height="1fr" pad="1">
      <text class="k-title">empty state</text>
      <!-- USE: the k-empty template fills the space left and centers an
           icon, a title and one line of help, all props (the icon and the
           text are optional), then its content: the call to action. The
           button, its id and its action are yours (deploy__create fires
           deploy_create), so the use needs no id and reads no data. Show it
           with `if="!items.any"` on the <use>, next to the list it
           replaces. -->
      <use template="k-empty" icon="◌" title="No deployments yet" text="Push a commit or create one by hand.">
        <button id="deploy__create" class="k-btn primary" label="New deployment" on:click="deploy_create"/>
      </use>
    </col>
  </screen>
</tui>

log panelk-log

a scrolling log that follows its end

$ tuimark play kit/components/log.tui --data kit/components/log.sample.json --cols 72 --rows 1272×12
a bordered build log with timestamps, a warning and a failed test in color, over its scroll hintsa bordered build log with timestamps, a warning and a failed test in color, over its scroll hints
takes
with="PATH as l" reads l.title and l.lines[] {n, text, debug, info, warn, err}; the host appends lines and writes the title
actions
log_append (the host's key)
keys
j and k scroll, g top, G follow
needs
k-hints
Template: k-log in kit.tui
kit/kit.tui
<!-- k-log: a scrolling log that follows its end. Props: style.
     with="PATH as l": l.title and l.lines, an array of {n, text, debug,
     info, warn, err}. Its scroll is U__view. -->
<template id="k-log" props="style">
  <scroll id="view" class="k-log" stick="bottom" focusable="true" title="{l.title}" style="{$style}">
    <col class="k-log-lines" each="l.lines as line" key="line.n">
      <text class="k-log-line" class:muted="line.debug" class:info="line.info" class:warn="line.warn" class:danger="line.err">{line.text}</text>
    </col>
  </scroll>
</template>
In use: components/log.tui
kit/components/log.tui
<!-- k-log · Contract: with="PATH as l" reads l.title and l.lines[] {n, text, debug, info, warn, err}; the host appends lines and writes the title · Actions: log_append (the host's key) · Keys: j and k scroll, g top, G follow · Requires: k-hints -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <!-- The log's scroll is log__view (the use's id, then the template's
       `view`): a keymap names it to give it keys. -->
  <keymap when="#log__view">
    <bind keys="j" action="move-next" keycap="j/k" label="scroll"/>
    <bind keys="k" action="move-prev"/>
    <bind keys="G" action="move-last" label="follow"/>
    <bind keys="g" action="move-first" label="top"/>
  </keymap>
  <screen id="demo" focus="#log__view">
    <col width="1fr" height="1fr" gap="0">
      <!-- USE: the k-log template is a focusable scroll with
           `stick="bottom"`: it follows the end of its content as lines are
           appended, until you scroll up to read; `move-last` (or scrolling
           to the end) makes it follow again. Each line is colored by its
           flags (debug, info, warn, err): every line carries all four,
           `false` for the ones it is not. The host appends lines to the
           array and writes the title (see examples/kit-gallery). -->
      <use id="log" template="k-log" with="log as l"/>
      <hints class="k-hints"/>
    </col>
  </screen>
</tui>

Data and input

data tablek-table

a table with a header, right-aligned numbers and columns that hide by priority

$ tuimark play kit/components/table.tui --data kit/components/table.sample.json --cols 72 --rows 1072×10
a data table of services with a header, state colors, right-aligned numbers and the cursor row as an accent bara data table of services with a header, state colors, right-aligned numbers and the cursor row as an accent bar
takes
reads services[] {id, name, state, ok, region, rps, p95} and count; reads and writes cur (the cursor row's id)
actions
table_select, table_open
keys
j and k move, enter opens
needs
k-hints
Markup: components/table.tui
kit/components/table.tui
<!-- k-table · Contract: reads services[] {id, name, state, ok, region, rps, p95} and count; reads and writes cur (the cursor row's id) · Actions: table_select, table_open · Keys: j and k move, enter opens · Requires: k-hints -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <keymap when="#svc">
    <bind keys="j" action="move-next"/>
    <bind keys="k" action="move-prev"/>
    <bind keys="enter" action="table_open" label="open"/>
  </keymap>
  <screen id="demo" focus="#svc">
    <col width="1fr" height="1fr" gap="0">
      <!-- COPY: a data table is a `table` with class `k-table`. The header
           is the `column` titles (bold, muted). Give a `column` the class
           `k-num` for numbers: the header and every cell of it align to the
           right. Columns with `priority` hide, lowest first, when the table
           is too narrow, so give the least important column the smallest
           number, and give the `1fr` column a `min-width` (the class
           `k-table-name`) so columns hide before it is squeezed. `bind`
           receives the cursor row's key; `on:select` fires as the cursor
           moves. The cursor row is bold on a quiet fill while the table is
           idle and a solid accent bar while it has focus. -->
      <table id="svc" class="k-table" each="services as s" key="s.id" bind="cur" title="Services · {count}" placeholder="no services" on:select="table_select">
        <column id="svc__name" class="k-table-name" title="SERVICE" width="1fr">{s.name}</column>
        <column id="svc__state" class="k-table-state" class:ok="s.ok" class:danger="!s.ok" title="STATE" width="9">{s.state}</column>
        <column id="svc__region" class="k-table-muted" title="REGION" width="10" priority="1">{s.region}</column>
        <column id="svc__rps" class="k-num" title="REQ/S" width="8" priority="2">{s.rps}</column>
        <column id="svc__p95" class="k-num" title="P95 MS" width="8" priority="3">{s.p95}</column>
      </table>
      <hints class="k-hints"/>
    </col>
  </screen>
</tui>

buttonk-btn

primary, secondary, danger and ghost, inverted when focused

$ tuimark play kit/components/button.tui --data kit/components/button.sample.json --cols 72 --rows 1172×11
primary, secondary, danger, ghost and disabled buttons, the focused one invertedprimary, secondary, danger, ghost and disabled buttons, the focused one inverted
takes
reads last
actions
button_save, button_cancel, button_delete, button_skip
keys
tab and shift+tab move focus, enter or space presses, q quits
needs
k-title, k-subtitle, k-muted
Markup: components/button.tui
kit/components/button.tui
<!-- k-btn · Contract: reads last · Actions: button_save, button_cancel, button_delete, button_skip · Keys: tab and shift+tab move focus, enter or space presses, q quits · Requires: k-title, k-subtitle, k-muted -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <keymap>
    <bind keys="ctrl+c,q" action="quit"/>
  </keymap>
  <screen id="demo" focus="#buttons__primary">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">button</text>
      <text class="k-subtitle">tab / shift+tab moves focus; enter or space presses</text>
      <!-- COPY: a button is `k-btn` plus a modifier: primary, secondary,
           danger, ghost. `on:click` names the action (component_verb); the
           host implements it. The focused button is drawn inverted, bold and
           underlined (see `.k-btn:focus`). -->
      <row width="1fr" height="1" gap="2">
        <button id="buttons__primary" class="k-btn primary" label="Save" on:click="button_save"/>
        <button id="buttons__secondary" class="k-btn secondary" label="Cancel" on:click="button_cancel"/>
      </row>
      <row width="1fr" height="1" gap="2">
        <button id="buttons__danger" class="k-btn danger" label="Delete" on:click="button_delete"/>
        <button id="buttons__ghost" class="k-btn ghost" label="Skip" on:click="button_skip"/>
        <button id="buttons__off" class="k-btn secondary" label="Locked" disabled="true"/>
      </row>
      <text class="k-muted">last action: {last}</text>
    </col>
  </screen>
</tui>

form fieldk-field

a label, an input, help text and an error line, with invalid styling

$ tuimark play kit/components/field.tui --data kit/components/field.sample.json --cols 72 --rows 1472×14
a form with a focused name field and an email field showing its error messagea form with a focused name field and an email field showing its error message
takes
props label, placeholder, help, style; with="forms.FORM.FIELD as f" reads f.error ("" when fine; the host writes it), and reads and writes f.value; the host also writes forms.FORM.valid, which the markup does not read
actions
form_validate, form_submit
keys
ctrl+s saves, enter in an input submits
needs
k-btn, k-hints, k-title
Template: k-field in kit.tui
kit/kit.tui
<!-- k-field: a form field. Props: label, placeholder, help, style.
     with="forms.FORM.FIELD as f": f.value (the input writes it), f.error
     ("" when fine). Use it as <use id="FORM__FIELD" …/>: the input is
     FORM__FIELD__input, and fires form_validate and form_submit. -->
<template id="k-field" props="label placeholder help style">
  <col class="k-field" style="{$style}">
    <text class="k-field-label" class:invalid="f.error">{$label}</text>
    <input id="input" class="k-field-input" class:invalid="f.error" bind="f.value" placeholder="{$placeholder}" on:change="form_validate" on:submit="form_submit"/>
    <text class="k-field-help" if="!f.error">{$help}</text>
    <text class="k-field-error" if="f.error">{f.error}</text>
  </col>
</template>
In use: components/field.tui
kit/components/field.tui
<!-- k-field · Contract: props label, placeholder, help, style; with="forms.FORM.FIELD as f" reads f.error ("" when fine; the host writes it), and reads and writes f.value; the host also writes forms.FORM.valid, which the markup does not read · Actions: form_validate, form_submit · Keys: ctrl+s saves, enter in an input submits · Requires: k-btn, k-hints, k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <keymap>
    <bind keys="ctrl+s" action="form_submit" keycap="^S" label="save"/>
  </keymap>
  <screen id="demo" focus="#profile__name__input">
    <col width="1fr" height="1fr" gap="0" pad="1">
      <text class="k-title">form field</text>
      <!-- USE: one k-field per field: a label, an input with its own border
           (so `:focus` can change its color), help text, and an error line.
           The use's id is FORM__FIELD, so the input is FORM__FIELD__input:
           here profile__name__input and profile__email__input, over
           forms.profile.name and forms.profile.email. The host writes the
           error ("" when fine): `invalid` turns the label and the border
           red, and the error line takes the help line's place. -->
      <use id="profile__name" template="k-field" label="Name" placeholder="your name" help="Shown on your profile." with="forms.profile.name as f"/>
      <use id="profile__email" template="k-field" label="Email" placeholder="you@example.com" help="We never share it." with="forms.profile.email as f"/>
      <row width="1fr" height="1" gap="2">
        <button id="profile__save" class="k-btn primary" label="Save" on:click="form_submit"/>
        <hints class="k-hints"/>
      </row>
    </col>
  </screen>
</tui>

Inline and chat

composerk-composer

a message box that grows with its text, with the key hints of your keymap

$ tuimark play kit/components/composer.tui --data kit/components/composer.sample.json --cols 72 --rows 872×8
a composer at the bottom of the screen: a rule, the placeholder text of an empty message box, and a row of key hintsa composer at the bottom of the screen: a rule, the placeholder text of an empty message box, and a row of key hints
takes
props placeholder, style; with="PATH as c": c.draft (the textarea writes it; the host clears it after a send), flag c.disabled (optional)
actions
composer_change (every edit, value: the text), composer_submit (enter, value: the text)
keys
enter sends, shift+enter or alt+enter a new line, up and down move through the lines
needs
k-hints
Template: k-composer in kit.tui
kit/kit.tui
<!-- k-composer: the box a message is typed in, with its key hints.
     Props: placeholder, style. with="PATH as c": c.draft (the textarea
     writes it; the host clears it after a send, and the caret goes to
     the end), flag c.disabled (a disabled composer takes no focus and no
     key, so a keymap row for a plain key, an approval's y, can fire).
     Fires composer_change (every edit, with the text) and composer_submit
     (enter, with the text). Use it as <use id="NAME" …/>: the textarea is
     NAME__input, the id a keymap names (`when="#NAME__input:focus"`) and
     `focus=` gives the focus to. <hints/> lists the labeled rows of your
     keymap that a key would fire now. -->
<template id="k-composer" props="placeholder style">
  <col class="k-composer" style="{$style}">
    <rule class="k-composer-rule"/>
    <textarea id="input" class="k-composer-input" bind="c.draft" disabled="c.disabled" placeholder="{$placeholder}" on:change="composer_change" on:submit="composer_submit"/>
    <hints class="k-hints"/>
  </col>
</template>
In use: components/composer.tui
kit/components/composer.tui
<!-- k-composer · Contract: props placeholder, style; with="PATH as c": c.draft (the textarea writes it; the host clears it after a send), flag c.disabled (optional) · Actions: composer_change (every edit, value: the text), composer_submit (enter, value: the text) · Keys: enter sends, shift+enter or alt+enter a new line, up and down move through the lines · Requires: k-hints -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <keymap>
    <bind keys="ctrl+o" action="composer_tips" label="tips"/>
    <bind keys="ctrl+q" action="quit" label="quit"/>
    <bind keys="up" action="composer_recall" when="#composer__input:focus" label="history"/>
  </keymap>
  <screen id="demo" focus="#composer__input">
    <col width="1fr" height="1fr">
      <text class="k-muted">The transcript goes above the composer.</text>
      <spacer/>
      <!-- USE: the box a message is typed in, with its key hints. The
           textarea is composer__input (the use's id, then the template's):
           name it in `focus=` and in a `when="#composer__input:focus"`.
           It is one row when empty and grows with its text up to eight
           rows. Enter fires composer_submit with the text; the host replies
           by writing "" to the draft before it replies, since enter changes
           nothing in the text. A disabled composer (c.disabled) takes no
           focus and no key: an approval that wants a plain key (y) sets it
           while it shows. The hints list the labeled rows of the keymap
           that a key would fire now (up shows only on the first line). -->
      <use id="composer" template="k-composer" placeholder="Message the model" with="composer as c"/>
    </col>
  </screen>
</tui>

transcript blockk-block

a paragraph, heading, quote, list item, code block, or rule made of runs

$ tuimark play kit/components/block.tui --data kit/components/block.sample.json --cols 72 --rows 2672×26
a transcript block by block: a heading, a paragraph with code, emphasis and bold runs, a quote, two list items, a Go code block that keeps its indentation, and a rulea transcript block by block: a heading, a paragraph with code, emphasis and bold runs, a quote, two list items, a Go code block that keeps its indentation, and a rule
takes
props style; with="PATH as blk" over an element of an array of {id, runs, code, head, quote, item, rule}: runs is an array of strings or {text, class} (the classes k-strong, k-em and k-code style a run), the five flags are optional booleans (false when missing)
needs
k-strong, k-em, k-code
Template: k-block in kit.tui
kit/kit.tui
<!-- k-block: one block of a transcript, a paragraph by default. Props:
     style. with="PATH as blk": blk.runs, an array of runs (a string, or
     {text, class}; the classes k-strong, k-em, and k-code style a run);
     flags, each optional and false when missing: blk.code (a code block:
     its line breaks and spaces kept, pre-wrap), blk.head (a heading),
     blk.quote, blk.item (a list item), blk.rule (a horizontal rule, no
     text). The block schema is a pattern, not the language: one
     <use template="k-block" with="b as blk"/> per element of an array
     of {id, runs, …}. markdownToBlocks in examples/host-ts makes it from
     markdown. A block wraps at the width it is shown or committed at. -->
<template id="k-block" props="style">
  <text class="k-block" class:code="blk.code" class:head="blk.head" class:quote="blk.quote" class:item="blk.item" if="!blk.rule" runs="blk.runs" style="{$style}"/>
  <rule class="k-block-rule" if="blk.rule"/>
</template>
In use: components/block.tui
kit/components/block.tui
<!-- k-block · Contract: props style; with="PATH as blk" over an element of an array of {id, runs, code, head, quote, item, rule}: runs is an array of strings or {text, class} (the classes k-strong, k-em and k-code style a run), the five flags are optional booleans (false when missing) · Actions: none · Keys: none · Requires: k-strong, k-em, k-code -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <scroll width="1fr" height="1fr" pad="1">
      <!-- USE: one k-block per element of an array of {id, runs, …}. The
           block is a paragraph of runs; a flag turns it into a heading
           (head), a quoted paragraph (quote), a list item (item), a code
           block that keeps its line breaks and spaces (code, wrap:
           pre-wrap), or a horizontal rule (rule, no text). The schema is a
           pattern, not the language: markdownToBlocks in examples/host-ts
           makes it from markdown. The same use shows a transcript, and a
           host commits one block at a time into the scrollback with
           Commit (see the inline guide). Flags are read through the alias,
           so a block that omits one reads it as false with no diagnostic. -->
      <col each="blocks as b" key="b.id" width="1fr" height="auto">
        <use template="k-block" with="b as blk"/>
      </col>
    </scroll>
  </screen>
</tui>

tool receiptk-receipt

what a tool did: its call, its output kept as runs, and a status line

$ tuimark play kit/components/receipt.tui --data kit/components/receipt.sample.json --cols 72 --rows 1672×16
two tool receipts: a successful ls with its tab-separated columns kept and a failed test run with its error in bold, each a bordered box with its status belowtwo tool receipts: a successful ls with its tab-separated columns kept and a failed test run with its error in bold, each a bordered box with its status below
takes
props style; with="PATH as r": r.title (the call), r.status, r.output (a string or an array of runs, shown as runs so its tabs are four spaces and its line breaks kept), flags r.ok and r.err
Template: k-receipt in kit.tui
kit/kit.tui
<!-- k-receipt: what a tool did. Props: style. with="PATH as r": r.title
     (the call: "bash · ls -la"), r.status ("exit 0 · 0.2s"), r.output (a
     string or an array of runs: the tool's output as runs, not as a
     {path}, which would remove its tabs), flags r.ok and r.err. -->
<template id="k-receipt" props="style">
  <box class="k-receipt" class:ok="r.ok" class:danger="r.err" title="{r.title}" style="{$style}">
    <text class="k-receipt-out" runs="r.output"/>
    <text class="k-receipt-status" if="r.status">{r.status}</text>
  </box>
</template>
In use: components/receipt.tui
kit/components/receipt.tui
<!-- k-receipt · Contract: props style; with="PATH as r": r.title (the call), r.status, r.output (a string or an array of runs, shown as runs so its tabs are four spaces and its line breaks kept), flags r.ok and r.err · Actions: none · Keys: none · Requires: none -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <!-- USE: what a tool did, as a bordered receipt: its call in the
           title, its output below, a status line last. The output is shown
           with `runs`, not a {path}: a {path} removes a TAB, and run text
           makes it four spaces, so a tool's `ls -l` keeps its columns. A
           flag colors the border (ok, err); both are optional. A host
           commits a receipt as a template's copy (Commit with this
           template), so it stays in the scrollback. -->
      <use template="k-receipt" with="ok_call as r"/>
      <use template="k-receipt" with="failed_call as r"/>
    </col>
  </screen>
</tui>

Overlays

confirm dialogk-confirm

a modal that puts the cursor on the safe button

$ tuimark play kit/components/confirm.tui --data kit/components/confirm.sample.json --cols 72 --rows 1672×16
a confirm dialog over the page asking to delete a project, with Cancel and Delete buttonsa confirm dialog over the page asking to delete a project, with Cancel and Delete buttons
takes
with="PATH as d" reads d.open, d.title, d.body, d.no and d.yes (the button labels) and the flag d.danger; slot: more body under d.body; the host writes d.open, and here confirm.result
actions
dialog_open, dialog_confirm, dialog_cancel
keys
y confirms, n and esc cancel
needs
k-btn, k-title, k-muted
Template: k-confirm in kit.tui
kit/kit.tui
<!-- k-confirm: a confirm dialog that puts the cursor on the safe button,
     sized by its content (up to 60 columns, where the text wraps).
     Props: style. with="PATH as d": d.open, d.title, d.body, d.no and d.yes
     (the button labels, which name the choices; the host writes them on
     every open); flag d.danger. Slot: more body under d.body (a list, a
     checkbox); its paths are written in full, d does not exist there.
     Variant: danger. Fires dialog_confirm and dialog_cancel (esc too, and y
     and n while it is open), from U__yes, U__no or U__dialog. -->
<template id="k-confirm" props="style">
  <modal id="dialog" class="k-dialog" class:danger="d.danger" open="d.open" title="{d.title}" focus="#no" on:escape="dialog_cancel" style="{$style}">
    <text class="k-dialog-text">{d.body}</text>
    <slot/>
    <row class="k-dialog-actions">
      <spacer/>
      <button id="no" class="k-btn secondary" label="{d.no}" on:click="dialog_cancel"/>
      <button id="yes" class="k-btn primary" label="{d.yes}" on:click="dialog_confirm"/>
    </row>
  </modal>
</template>
In use: components/confirm.tui
kit/components/confirm.tui
<!-- k-confirm · Contract: with="PATH as d" reads d.open, d.title, d.body, d.no and d.yes (the button labels) and the flag d.danger; slot: more body under d.body; the host writes d.open, and here confirm.result · Actions: dialog_open, dialog_confirm, dialog_cancel · Keys: y confirms, n and esc cancel · Requires: k-btn, k-title, k-muted -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <screen id="demo" focus="#confirm__open">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">confirm dialog</text>
      <row width="1fr" height="1" gap="2">
        <button id="confirm__open" class="k-btn danger" label="Delete project" on:click="dialog_open"/>
      </row>
      <text class="k-muted">result: {confirm.result}</text>
    </col>
    <!-- USE: the k-confirm template, as the LAST child of the screen (it is
         a modal, L004). The use's id is the instance: its parts are
         confirm__dialog, confirm__no and confirm__yes, and a host routes
         dialog_confirm and dialog_cancel by the part of the event's source
         before the last "__". `class="danger"` makes a destructive dialog
         (or set the flag d.danger from data). The cursor starts on the SAFE
         button, so a stray enter cancels; esc cancels too, and y / n work
         (the kit's <keymap when=".k-dialog">). The dialog takes the size
         of its content: as wide as the title, the text or the action row,
         up to 60 columns (and the screen), where the text wraps, and as
         tall as its content. Keep the labels short: the action row must fit
         a 40-column terminal. -->
    <use id="confirm" template="k-confirm" class="danger" with="confirm as d">
      <text class="k-muted">{confirm.detail}</text>
    </use>
  </screen>
</tui>

help overlayk-help

a modal that lists every labeled key

$ tuimark play kit/components/help.tui --data kit/components/help.sample.json --cols 72 --rows 1772×17
a help overlay listing every labeled key bindinga help overlay listing every labeled key binding
takes
props title, style; with="PATH as h" reads h.open; lists every keymap row that has a label
actions
help_open, help_close (the demo also names item_new, item_delete, item_next, item_prev, item_save)
keys
? opens, q and ? close
needs
k-hints, k-title, k-muted
Template: k-help in kit.tui
kit/kit.tui
<!-- k-help: every labeled key, under its own "? close help" line, in a
     scroll (U__keys) for a long keymap. Props: title, style.
     with="PATH as h": h.open. -->
<template id="k-help" props="title style">
  <modal id="dialog" class="k-help" open="h.open" title="{$title}" on:escape="help_close" style="{$style}">
    <row class="k-help-close">
      <text class="k-help-key">?</text>
      <text class="k-help-label">close help</text>
    </row>
    <scroll id="keys" class="k-help-scroll" focusable="true">
      <hints class="k-hints k-help-keys" scope="all"/>
    </scroll>
  </modal>
</template>
In use: components/help.tui
kit/components/help.tui
<!-- k-help · Contract: props title, style; with="PATH as h" reads h.open; lists every keymap row that has a label · Actions: help_open, help_close (the demo also names item_new, item_delete, item_next, item_prev, item_save) · Keys: ? opens, q and ? close · Requires: k-hints, k-title, k-muted -->
<tui theme="auto">
  <!-- The kit comes first, with its overlay keys: q and ? close the help
       (<keymap when=".k-help">) before they reach the global rows below,
       since the first matching row in document order wins. -->
  <include src="../kit.tui"/>
  <!-- The help overlay shows its own "? close help" line, then every
       keymap row that has a `label`: these. (The kit's overlay keys have no
       label, so no <hints> lists them.) Give rows a `keycap` to show "j/k"
       or "^S" instead of the raw key. -->
  <keymap>
    <bind keys="?" action="help_open" label="help"/>
    <bind keys="n" action="item_new" label="new item"/>
    <bind keys="d" action="item_delete" label="delete item"/>
    <bind keys="j" action="item_next" keycap="j/k" label="move"/>
    <bind keys="k" action="item_prev"/>
    <bind keys="ctrl+s" action="item_save" keycap="^S" label="save"/>
    <bind keys="q" action="quit" label="quit"/>
  </keymap>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">help overlay</text>
      <text class="k-muted">press ? for the keys</text>
      <hints class="k-hints"/>
    </col>
    <!-- USE: the k-help template, as the last child of the screen: a modal
         that holds `<hints scope="all">`, every labeled row, not only the
         ones that would fire right now. It is 56 columns wide and as tall
         as its content. -->
    <use id="help" template="k-help" title="Keys" with="help as h"/>
  </screen>
</tui>

command palettek-palette

a modal with an input over a filtered list

$ tuimark play kit/components/palette.tui --data kit/components/palette.sample.json --cols 72 --rows 1472×14
a command palette with a query typed and the matching commands listeda command palette with a query typed and the matching commands listed
takes
props title, placeholder, style; with="PATH as p, FOUND as f" reads and writes p.open, p.query and p.cur, and reads f.any and f.items[] {id, label, hint} (the host keeps FOUND with a Derive over p.query and the commands)
actions
palette_open, palette_run, palette_close, palette_query (fires as the query changes; a Go host that filters with Derive needs no work in it, a TypeScript parent recomputes FOUND there)
keys
ctrl+k opens, up and down (or ctrl+p and ctrl+n) move, enter runs, esc closes
needs
k-hints, k-title, k-muted
Template: k-palette in kit.tui
kit/kit.tui
<!-- k-palette: a command palette. Props: title, placeholder, style.
     with="PATH as p, FOUND as f": p.open, p.query (the input writes it),
     p.cur (the list's cursor); f.any and f.items, an array of
     {id, label, hint} that the host keeps (a Derive over p.query). Fires
     palette_query, palette_run and palette_close (esc). Its arrows move
     U__list while the input keeps focus: add the rows that name it to your
     keymap. -->
<template id="k-palette" props="title placeholder style">
  <modal id="dialog" class="k-palette" open="p.open" title="{$title}" focus="#q" on:escape="palette_close" style="{$style}">
    <input id="q" class="k-palette-input" bind="p.query" placeholder="{$placeholder}" on:change="palette_query" on:submit="palette_run"/>
    <text class="k-palette-empty" if="!f.any">No command matches “{p.query}”.</text>
    <list id="list" class="k-palette-list" each="f.items as cmd" key="cmd.id" bind="p.cur" focusable="false">
      <item>
        <row class="k-palette-row">
          <text class="k-palette-label">{cmd.label}</text>
          <text class="k-palette-hint">{cmd.hint}</text>
        </row>
      </item>
    </list>
  </modal>
</template>
In use: components/palette.tui
kit/components/palette.tui
<!-- k-palette · Contract: props title, placeholder, style; with="PATH as p, FOUND as f" reads and writes p.open, p.query and p.cur, and reads f.any and f.items[] {id, label, hint} (the host keeps FOUND with a Derive over p.query and the commands) · Actions: palette_open, palette_run, palette_close, palette_query (fires as the query changes; a Go host that filters with Derive needs no work in it, a TypeScript parent recomputes FOUND there) · Keys: ctrl+k opens, up and down (or ctrl+p and ctrl+n) move, enter runs, esc closes · Requires: k-hints, k-title, k-muted -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <!-- The overlay's own keys come first (the first matching row in document
       order wins). While the palette is open, up / down (and ctrl+n /
       ctrl+p) move the cursor of its list although focus stays in the
       input: the input does not consume them, so they reach the keymap,
       and the built-ins act on the list named by `to`. The list is
       palette__list (the use's id, then the template's `list`), so these
       rows live in the document, not in the kit: a kit row that named it
       would fail in every document without that palette. Enter is the
       input's `on:submit`; esc is the modal's `on:escape`. -->
  <keymap when=".k-palette">
    <bind keys="down,ctrl+n" action="move-next" to="#palette__list"/>
    <bind keys="up,ctrl+p" action="move-prev" to="#palette__list"/>
  </keymap>
  <keymap>
    <bind keys="ctrl+k" action="palette_open" keycap="^K" label="commands"/>
  </keymap>
  <screen id="demo">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">command palette</text>
      <text class="k-muted">ctrl+k opens it; type, up / down, enter, esc.</text>
      <text class="k-muted">last command: {palette.last}</text>
      <hints class="k-hints"/>
    </col>
    <!-- USE: the k-palette template, as the last child of the screen: an
         input bound to the query over a list of the commands that match.
         The filtering is the HOST's job (no expressions in the markup): keep
         `found` with a Derive over `palette.query` and the commands, and
         pass it as the second alias. The list's `bind` is the cursor row's
         id. The palette is 60 by 16, at most the screen. -->
    <use id="palette" template="k-palette" title="Command palette" placeholder="type a command…" with="palette as p, found as f"/>
  </screen>
</tui>

toastk-toast

a one-row notice that never moves the page

$ tuimark play kit/components/toast.tui --data kit/components/toast.sample.json --cols 72 --rows 1072×10
a toast along the bottom row saying the settings were saved, with esc to dismissa toast along the bottom row saying the settings were saved, with esc to dismiss
takes
with="PATH as t" reads t.show, t.text, and the flags t.is_ok, t.is_warn and t.is_danger; the host clears t.show after a few seconds
actions
toast_show, toast_dismiss
keys
esc dismisses
needs
k-btn, k-title
Template: k-toast in kit.tui
kit/kit.tui
<!-- k-toast: a one-row notice that never moves the page. Props: style.
     with="PATH as t": t.show, t.text; flags t.is_ok, t.is_warn,
     t.is_danger. -->
<template id="k-toast" props="style">
  <row class="k-toast-slot" style="{$style}">
    <row class="k-toast" if="t.show" class:ok="t.is_ok" class:warn="t.is_warn" class:danger="t.is_danger">
      <text class="k-toast-text">{t.text}</text>
      <text class="k-toast-key">esc</text>
    </row>
  </row>
</template>
In use: components/toast.tui
kit/components/toast.tui
<!-- k-toast · Contract: with="PATH as t" reads t.show, t.text, and the flags t.is_ok, t.is_warn and t.is_danger; the host clears t.show after a few seconds · Actions: toast_show, toast_dismiss · Keys: esc dismisses · Requires: k-btn, k-title -->
<tui theme="auto">
  <include src="../kit.tui"/>
  <keymap>
    <bind keys="esc" action="toast_dismiss" label="dismiss"/>
  </keymap>
  <screen id="demo" focus="#toast__show">
    <col width="1fr" height="1fr" gap="1" pad="1">
      <text class="k-title">toast</text>
      <row width="1fr" height="1" gap="2">
        <button id="toast__show" class="k-btn primary" label="Save" on:click="toast_show"/>
      </row>
      <spacer/>
      <!-- USE: the k-toast template is a one-row slot that is always there,
           so the page never jumps when the toast appears; the toast inside
           shows only while t.show is true. Info is the default; the flags
           t.is_ok, t.is_warn and t.is_danger pick another level. The HOST
           clears it: set t.show back to false from an `Every` tick (see
           examples/kit-gallery/main.go). The slot is not docked, so it can
           sit above a docked status bar (only one bottom-docked bar per
           container, L005). -->
      <use template="k-toast" with="toast as t"/>
    </col>
  </screen>
</tui>