Widgets
Code Editor
Write Widget code, define the schema and preview with examples in the code editor.
The Code tab is where you write and edit a Widget by hand. It has two parts: the main editor at the top, where you write the Widget's layout, and the footer panel at the bottom, where you define the schema and manage example data.
Main Editor
The main editor is where you write the Widget's layout with the built-in components. Its toolbar has:
- JSON: switches between Widget code (the JSX layout) and Widget JSON (the same Widget as its rendered element tree). You can edit either view.
- Widget images: upload images and insert their URLs. See Widget images.
- Copy code: copies the editor's contents to your clipboard.
The editor highlights JSX syntax so the structure is easy to read.
Code Syntax
The code editor uses a JSX-like syntax. These are the main patterns for working with data in a Widget.
Variables
Use a data field by putting its name in curly braces. Each variable is a field in the schema.
<Title value={orderNumber} size="sm" />
<Text value={estimatedDelivery} size="sm" color="secondary" />Nested Data
Reach into nested objects with dot notation.
<Text value={customer.name} />
<Text value={customer.email} />Loops
Repeat elements for each entry in an array with .map().
{items.map((item) => (
<Row key={item.id} gap={3}>
<Image src={item.image} size={40} />
<Text value={item.name} size="sm" />
</Row>
))}String Interpolation
Mix fixed text with data fields using backticks and ${}.
<Text value={`Qty ${item.quantity}`} />Conditions and Expressions
Show an element only when a value is set with &&, choose between two values with a ternary, and compare or calculate with the usual operators. Method calls other than .map() aren't supported, so format values such as prices in your data.
{trackingUrl && <Badge label="Tracking available" color="info" />}
<Icon name={step.done ? "circle-check" : "circle"} color={step.done ? "success" : "tertiary"} />
<Text value={`$${(price * quantity)}`} />Schema
The Schema tab in the footer panel defines the data fields the AI agent provides when it shows the Widget. Write it in Zod, or switch to JSON to write it as a JSON Schema.
Use the Zod / JSON switch on the right of the footer panel to change format.
Default Example
The Default tab holds the starting values for every schema field. The preview uses them when the Widget first shows, and visitors see them for any field no other source provides.
{
"orderNumber": "QW-10482",
"status": "Shipped",
"estimatedDelivery": "Mar 9, 2026"
}Named Examples
Named examples let you preview other sets of data without changing the default values. Use them to see how the Widget looks with, say, 1 item against 5, or an order that's still processing against one that's been delivered.
- Add an example
Click Add example (+) in the footer panel. The new tab, Example 1, starts as a copy of Default.
- Edit its values
Change the values in the example's tab. Each example keeps its own data.
- Switch between examples
Click an example's tab to update the preview with its data. Click the × on a tab to close that example.
A new example starts as a copy of Default.
Widget Images
Click Widget images in the toolbar to manage the images hosted for this Widget. Upload a PNG, JPEG, WebP or GIF of up to 5 MB, up to 5 images per Widget. Each image has Copy URL, Insert, which puts its URL into the code, and Delete image.