Skip to content

Gen UI frame

Lets an agent answer with an interface instead of a paragraph. It streams a JSON spec, and the frame builds the real components from it as the spec arrives: stats, a table, a chart, a form, buttons. Only whitelisted types are drawn, nothing is evaluated, clicks go back to the agent, and a view spec toggle shows the JSON beside the result.

On this page

Examples

Unknown types and bad props

Your own type

Installation

Installation is part of Pro

Pro components install from a licensed registry. The live preview stays open to everyone.

Props

specrequired
string | object | null
The spec as JSON text, as much as has arrived (any prefix of a valid document works), or an object. A node is { type, id?, ...props, children? }.
streaming
boolean
Defaultfalse
The agent is still sending. New nodes fade in, and the controls are disabled until it ends, so a half-built form cannot be sent.
registry
Record<string, renderer | { render, spec? }>
Adds a type or replaces a built-in one. A renderer gets { node, children, ctx }. With `spec` ({ props: { name: check }, container }) its props are checked; without it every plain JSON prop is passed through.
onAction
(action: GenUiAction) => void
A button was pressed: { action, id, label?, payload?, values }. `values` holds every field in the frame by name, so the agent sees what the person entered.
onValuesChange
(values) => void
A field changed, or fields appeared as the spec grew.
showSpec / defaultShowSpec / onShowSpecChange
boolean / boolean / (show) => void
Defaultfalse
The View spec toggle. The JSON sits beside the UI from 672px of frame width up and below it under that. While streaming it is the raw text; when whole, formatted JSON with the issues listed under it.
title
ReactNode
DefaultGenerated interface
The heading and the name of the region.
empty
ReactNode
Shown before anything has arrived.
specMaxHeight
number
Default420
Height cap of the spec pane.
Built-in types
whitelist
stack, card, text, badge, stat, table, chart, input, textarea, select, switch, button, divider. Each has a schema in DEFAULT_SPECS: unknown props are dropped, bad values are dropped, sizes are capped (200 nodes, 8 levels, 200 table rows, 2,000 characters of text) and every drop is an issue.
Safety
no eval
A spec is data. There is no HTML, no style, no link and no event handler in the vocabulary, text is drawn as text, and keys such as __proto__ are skipped by the parser. A type that is not registered draws its name and none of its props.
parsePartial / validateSpec
functions
The parser and validator on their own, from gen-ui-frame. parsePartial(text) gives { value, complete, error? } for any prefix; validateSpec(value, { complete, specs }) gives { tree, issues, count }.
Motion
arrival
A node that mounts while streaming fades and rises 4px in 180 ms, staggered by 40 ms for at most four nodes per update. A static spec, a re-render and a changed prop play nothing. Reduced motion is instant.
a11y
region
The frame is a named region and aria-busy while streaming. The build status is read once, when the stream ends, not on every chunk. The View spec button is a toggle (aria-pressed) that controls the pane. Fields have labels and a disabled state, never colour alone.

When to use

When to use

  • An agent that should answer with something to use: a batch to review, a form to fill, a chart to read, not a paragraph about it.
  • A chat turn where the interface is not known in advance and must be built from what the agent decides to show, safely.

When not to use

  • A canvas for a document or code the agent is writing: use Artifact Canvas.
  • An answer where each sentence is tied to its source: use Grounded Answer.
  • A fixed form you design yourself: use Input.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Gen UI Frame to my app and wire it to my own data.
  • I need an agent that should answer with something to use: a batch to review, a form to fill, a chart to read, not a paragraph about it. Set that up with the Knowns UI Gen UI Frame.
  • Which Gen UI Frame props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "gen-ui-frame" }) and search_docs({ query: "gen ui frame" }). Pro props, full examples and source come back once your license key is in the MCP config.

Need help?

Stuck on Gen UI Frame, or found something off? We read every message.