OpenUI

OpenUI Lang Syntax

Expression grammar and common component signatures.

OpenUI Lang is line-oriented:

identifier = Expression

Example:

root = Stack([title, form])
title = TextContent("Sign up", "large-heavy")
form = Form("signup", actions, [nameField, emailField])
nameField = FormControl("Name", Input("name", "Your name", "text", {required: true}))
emailField = FormControl("Email", Input("email", "you@example.com", "email", {required: true, email: true}))
actions = Buttons([submitBtn, cancelBtn], "row")
submitBtn = Button("Submit", @ToAssistant("Sign me up"), "primary")
cancelBtn = Button("Cancel", @ToAssistant("Cancel sign up"), "secondary")

Supported expression types

TypeSyntaxExample
Component callTypeName(arg1, arg2)CardHeader("Title", "Subtitle")
String"text""hello"
Number42, 3.14, -13.14
Booleantrue / falsetrue
Nullnullnull
Array[a, b, c][col1, col2]
Object{key: value}{variant: "info"}
ReferenceidentifiernameField

Rules

  • root is the entry point. Without it, the first statement that calls the root component is used.
  • For OpenUI library prompts, start with root = Stack(...).
  • Arguments are positional, based on Zod key order.
  • Optional args can be omitted from the end.
  • Forward references are allowed.

Common default-library signatures

These are the signatures in openuiLibrary from @openuidev/react-ui.

ComponentSignature
StackStack(children, direction?, gap?, align?, justify?, wrap?)
CardCard(children, variant?, direction?, gap?, align?, justify?, wrap?)
TextContentTextContent(text, size?)
FormForm(name, buttons, fields?)
FormControlFormControl(label, input, hint?)
InputInput(name, placeholder?, type?, rules?, value?)
SelectSelect(name, items, placeholder?, rules?, value?, size?)
ButtonButton(label, action?, variant?, type?, size?)
ButtonsButtons(buttons, direction?)
TabsTabs(items)
TabItemTabItem(value, trigger, content)
TableTable(columns)
ColCol(label, data, type?)
BarChartBarChart(labels, series, variant?, xLabel?, yLabel?, height?)

For full generated signatures, inspect:

openuiLibrary.prompt(openuiPromptOptions);

On this page