gridland
Components

TUI Primitives

Built-in JSX elements for terminal UI rendering

Gridland uses JSX intrinsic elements that map to renderable components in the opentui engine. These are used inside <TUI>.

Primitives
?

Run demo

Terminal
bunx @gridland/demo primitives
Terminal
curl -fsSL https://raw.githubusercontent.com/thoughtfulllc/gridland/main/scripts/run-demo.sh | bash -s primitives

These are JSX intrinsic elements, not DOM elements. <box> renders to the canvas cell grid, not to an HTML <div>. They only work inside a <TUI> wrapper.

<box>

A container element with flexbox layout support.

Box example
<box
  flexDirection="column"
  padding={1}
  border
  borderStyle="rounded"
  borderColor="#5e81ac"
  backgroundColor="#2e3440"
>
  {children}
</box>

Box Props

PropTypeDescription
flexDirection"row" | "column"Layout direction
paddingnumberPadding in cells
marginnumberMargin in cells
borderbooleanShow border
borderStyle"single" | "rounded" | "double" | "bold"Border style
borderColorstringBorder color (hex)
backgroundColorstringBackground color (hex)
titlestringBorder title text
titleAlignment"left" | "center" | "right"Title position
flexGrownumberFlex grow factor
flexShrinknumberFlex shrink factor
widthnumber | stringWidth in cells or percentage
heightnumber | stringHeight in cells or percentage
gapnumberGap between children

<text>

Renders styled text content.

Text example
<text fg="#a3be8c" bold>
  Hello World
</text>

Text Props

PropTypeDescription
fgstringForeground color (hex)
bgstringBackground color (hex)
boldbooleanBold text
italicbooleanItalic text
underlinebooleanUnderlined text
dimbooleanDimmed text

<input>

A text input field.

Input example
<input
  placeholder="Type here..."
  onInput={(value) => console.log(value)}
  onSubmit={(value) => console.log("Submitted:", value)}
/>

<select>

A selection list.

Select example
<select
  options={[
    { label: "Option A", value: "a" },
    { label: "Option B", value: "b" },
  ]}
  onChange={(index, option) => console.log(option)}
/>

<scrollbox>

A scrollable container.

Scrollbox example
<scrollbox height={10}>
  {/* Content taller than 10 rows will scroll */}
</scrollbox>

<code>

Syntax-highlighted code block.

Code example
<code content="const x = 42" filetype="typescript" />

<markdown>

Rendered markdown content.

Markdown example
<markdown content="# Hello\n\nThis is **bold** text." />