Skip to content
QwryAI
Documentation
Pages

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.

The Code tab: main editor above, footer panel below.

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.

JSON shows the Widget as its element tree.

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.

jsx
<Title value={orderNumber} size="sm" />
<Text value={estimatedDelivery} size="sm" color="secondary" />

Nested Data

Reach into nested objects with dot notation.

jsx
<Text value={customer.name} />
<Text value={customer.email} />

Loops

Repeat elements for each entry in an array with .map().

jsx
{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 ${}.

jsx
<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.

jsx
{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.

The schema as a JSON Schema.

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.

JSON
{
  "orderNumber": "QW-10482",
  "status": "Shipped",
  "estimatedDelivery": "Mar 9, 2026"
}
Default holds the starting values.

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.

  1. Add an example

    Click Add example (+) in the footer panel. The new tab, Example 1, starts as a copy of Default.

  2. Edit its values

    Change the values in the example's tab. Each example keeps its own data.

  3. 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.

Upload, copy and insert hosted images.

Next steps

Explore the documentation