Generative ui

From BuilderIO/agent-native · View interactive version

Generative ui is an AI agent skill from the GitHub repository BuilderIO/agent-native. Generate transient or saved inline chat UI with Alpine/Tailwind controls, outputs, app state, and extensions. Use for knobs, pickers, calculators, dashboards, widgets, or reusable mini-apps.

How to use this skill

Skill file

Generative UI

Generative UI is sandboxed Alpine.js HTML rendered inline in chat. It is not a

source-code change and does not go through Builder.

Pick the Lifetime

chat: knobs, controls, pickers, calculators, temporary charts, and previews.

the Extensions view. It also renders inline after creation.

Inputs From Chat

Pass initial values through the action context argument. The iframe reads them

from window.slotContext and can subscribe to changes with

window.onSlotContext(fn).

<script>
  Alpine.data("controls", () => ({
    threshold: 50,
    init() {
      this.threshold = Number(window.slotContext?.threshold ?? 50);
      window.onSlotContext?.((ctx) => {
        if (ctx.threshold !== undefined) {
          this.threshold = Number(ctx.threshold);
        }
      });
    },
  }));
</script>

Outputs To The Agent

Use passive output when a control's current value should be visible to the agent

on the next turn without requiring a submit click:

<input
  type="range"
  min="0"
  max="100"
  x-model.number="threshold"
  @input="agentNative.ui.output({ threshold }, { label: 'Threshold' })"
/>

agentNative.ui.output(value, opts?) writes application state at:

inline-ui:<extensionId>:output

The id is scoped automatically; the HTML author must not pass it. When the user

says "use that value", "apply the current setting", or "run it with the current

selection", read the value with:

const output = await readAppState("inline-ui:<id>:output");

The stored payload includes value, updatedAt, extensionId, and

source: "inline-ui", plus optional label, context, or meta.

Use agentNative.chat.send(message, opts?) or sendToAgentChat(message, opts?)

for a visible Apply/Submit button that should send a prompt or selected value

into the chat. Pass { submit: true } explicitly for that user-triggered

action; extension messages are draft-only otherwise. Never call these helpers

from polling, refresh, or error handlers.

App Data And State

/_agent-native/*, including application-state reads and writes.

Transient extensionData Boundary

For saved extensions, extensionData uses the authenticated database-backed

extension data API.

For transient inline UIs, extensionData is host localStorage. The agent

cannot read it, it does not sync across devices, it does not migrate when a UI

is promoted to a saved Extension, and the server does not garbage-collect it.

Use it only for throwaway local UI state.

For anything the agent or app must observe, use agentNative.ui.output,

application state through appFetch, an appAction, or

agentNative.chat.send.

Styling

Use semantic Tailwind classes so the iframe inherits the parent app theme:

Do not hardcode provider tokens, private data, or internal secrets in generated

HTML. Do not call an LLM directly from the iframe; route AI work through the

agent chat.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.