# ViteHub UI

An Agent meets UI in three ways. It builds UI as code, sends UI as a spec, or works the live page that a person has open. ViteHub UI gives each way one owner.

| Way | What you use |
| --- | --- |
| [Build UI as code](https://vitehub.dev/docs/ui#build-ui-as-code) | ui-sdk parts from `@ui-sdk/vue`, plus `@vite-hub/kit` for the parts and styles that ui-sdk does not have |
| [Send UI as a spec](https://vitehub.dev/docs/ui#send-ui-as-a-spec) | The Agent UI catalog in `vite-hub/agent/ui`, paired with forms from `@vite-hub/forms` |
| [Work the live page](https://vitehub.dev/docs/ui#work-the-live-page) | The `page()` Capability, with `connectPage()` from `vite-hub/agent/page` |

## Build UI as code

Import each part from its `@ui-sdk/vue` entry. Every part handles behavior, focus, keyboard navigation, and ARIA, and has no styles. `@vite-hub/kit` adds the parts that ui-sdk does not have, today `TagsInput`, and a style family for every part.

```vue [app/components/RenameDialog.vue]
<script setup lang="ts">
import {
  Dialog,
  DialogContent,
  DialogTitle,
  DialogTrigger,
} from "@ui-sdk/vue/dialog"
import { Field, FieldLabel } from "@ui-sdk/vue/field"
import { Input } from "@ui-sdk/vue/input"
</script>

<template>
  <Dialog>
    <DialogTrigger>Rename</DialogTrigger>
    <DialogContent>
      <DialogTitle>Rename the project</DialogTitle>
      <Field>
        <FieldLabel>Project name</FieldLabel>
        <Input default-value="Apollo" />
      </Field>
    </DialogContent>
  </Dialog>
</template>
```

Read [Get started](https://vitehub.dev/docs/ui/get-started) to install the parts and styles.

## Send UI as a spec

An Agent can reply with UI instead of text, such as an approval card. It writes a [json-render](https://json-render.dev) spec, and `vite-hub/agent/ui` checks it against the catalog of parts that it may send:

```json [approval.json]
{
  "root": "card",
  "elements": {
    "card": {
      "type": "Card",
      "props": { "title": "Deploy acme/web" },
      "children": ["approve"]
    },
    "approve": {
      "type": "Button",
      "props": { "label": "Approve", "variant": "primary" },
      "on": {
        "press": { "action": "event", "params": { "name": "deploy.approve" } }
      }
    }
  }
}
```

A spec has no inputs of its own. To ask for values, a `Form` names a form from `@vite-hub/forms`, so one schema makes the web form, the MCP elicitation, and the Slack modal. [Agent UI](https://vitehub.dev/docs/agents/ui) shows how to define the catalog, check a spec, and render it. See also [one schema on every surface](https://vitehub.dev/docs/forms/server-api#one-schema-on-every-surface) and [Forms in Vue](https://vitehub.dev/docs/forms/vue).

## Work the live page

The `page()` Capability lets a server Agent read and change the page that a person has open, through ui-sdk's agent bridge. You set which parts it may not touch and which steps need approval:

```ts [server/agents/settings.ts]
import { defineAgent } from "vite-hub/agent"
import { page } from "vite-hub/agent/capabilities"
import { webChat } from "vite-hub/channels/adapters"

export default defineAgent({
  capabilities: [page({ requireApproval: [{ label: "Save changes" }] })],
  channels: { web: webChat() },
  driver: { model: "openai/gpt-5" },
})
```

Read [Page](https://vitehub.dev/docs/agents/capabilities/page) for client setup, undo, and the security model.

## Next

- [Get started](https://vitehub.dev/docs/ui/get-started) installs the parts and styles, renders a field, and connects the page.
- [Where does it belong?](https://vitehub.dev/docs/ui/where-does-it-belong) maps each UI layer to its owner and tests.
- [From Reka UI](https://vitehub.dev/docs/ui/from-reka-ui) and [From Nuxt UI](https://vitehub.dev/docs/ui/from-nuxt-ui) migrate an app to ui-sdk parts.
- [AI components](https://vitehub.dev/docs/ui/ai-components) covers chat, sessions, Agent runs, and code views on Nuxt UI.
- [Playground](https://vitehub.dev/playground?template=ui) lets you edit a Vue app with ui-sdk parts in the browser.
- [Import paths](https://vitehub.dev/docs/reference/import-paths) lists every entry of `vite-hub/agent/ui`, `vite-hub/agent/page`, and `vite-hub/forms`.

<!-- vitehub-docs:section-links -->
## In this section

- Start
  - [Overview](https://vitehub.dev/raw/docs/ui.md) (this page)
  - [Get started](https://vitehub.dev/raw/docs/ui/get-started.md)
  - [Where does it belong?](https://vitehub.dev/raw/docs/ui/where-does-it-belong.md)
  - [From Reka UI](https://vitehub.dev/raw/docs/ui/from-reka-ui.md)
  - [From Nuxt UI](https://vitehub.dev/raw/docs/ui/from-nuxt-ui.md)
- [AI components](https://vitehub.dev/raw/docs/ui/ai-components.md)
- [Blocks](https://vitehub.dev/raw/docs/ui/blocks/chat-app.md)
- [Parts](https://vitehub.dev/raw/docs/ui/message.md)
- [Chat](https://vitehub.dev/raw/docs/ui/chat.md)
- [Collaboration](https://vitehub.dev/raw/docs/ui/avatar-stack.md)
- [Agent work](https://vitehub.dev/raw/docs/ui/tool-list.md)
- [Utilities](https://vitehub.dev/raw/docs/ui/attachments.md)

Next: [UI_R0001](https://vitehub.dev/raw/docs/ui/diagnostics/ui_r0001.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
