# Prompt Bar

The composer of an agent: a growing text field with attachments, a model picker and send.

The composer of an agent surface: a growing textarea with an attach menu, a model picker, dictation and send. Typing @ opens a list of sources and / a list of commands; the textarea keeps focus and the list follows the combobox pattern. Enter sends, Shift+Enter adds a line, and while the agent works the send button becomes a stop button. The model picker is our quiet select and the attach menu is our menu, so their behaviour comes from Zag in every target; the suggestion lists share one framework-neutral controller (prompt-suggest.ts).

Kind: block · Category: Agent · Status: beta · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add prompt-bar
```

It writes the folder `prompt-bar/` into the project's ui folder (`index.ts`, `prompt-bar.tsx`, `PromptBar.vue`, `PromptBar.svelte`, `prompt-bar.recipe.ts`), and what it is built from: [Select](/components/select.md), [Menu](/components/menu.md), [Button](/components/button.md), [Tag](/components/tag.md), [Empty State](/components/empty-state.md), [Tooltip](/components/tooltip.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { PromptBar } from "@/components/ui/prompt-bar";
```

```vue
import { PromptBar } from "@/components/ui/prompt-bar";
```

```svelte
import { PromptBar } from "$lib/components/ui/prompt-bar";
```

## Parts

In the DOM the root carries `data-slot="prompt-bar"` and each part `data-slot="prompt-bar-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `prompt-bar` |  | data-slot="prompt-bar"; shape, busy and the expanded layout (the text, or the placeholder while it is empty, needs the full width: controls drop to a second row, so a hint is never cut beside them) are recipe variants |
| `composer` | `div` | `prompt-bar-composer` |  | The bordered surface; anchors the suggestion lists |
| `sweep` | `canvas` | `prompt-bar-sweep` |  | glimm shader canvas behind the content, invisible at rest; data-sweeping while the send sweep plays |
| `attachments` | `div` | `prompt-bar-attachments` | optional | role=list of attached files |
| `attachment` | `span` | `prompt-bar-attachment` | repeats | The real Tag (tone neutral; shape pill in a pill bar, rounded otherwise) as role=listitem, marked data-prompt-bar="attachment"; the file glyph is its icon; a path-like name is middle-truncated |
| `attachment-remove` | `button` | `prompt-bar-attachment-remove` |  | The Tag's remove button (the real Button, ghost xs square, following the pill shape) with its tooltip Remove <name>; marked data-prompt-bar="attachment-remove" through removeProps (an attribute object passed to Tag) |
| `row` | `div` | `prompt-bar-row` |  | Grid of the input and the controls |
| `attach` | `div` | `prompt-bar-attach` |  | The real Menu, marked data-prompt-bar="attach", with the attach trigger |
| `attach-trigger` | `button` | `prompt-bar-attach-trigger` |  | The real Button (ghost sm square muted, rounded unless the bar is a pill), marked data-prompt-bar="attach-trigger"; aria-label Add attachments and sources |
| `input` | `textarea` | `prompt-bar-input` |  | role=combobox, aria-autocomplete=list, aria-expanded, aria-controls and aria-activedescendant while a list is open; grows to a maximum, then scrolls |
| `model` | `div` | `prompt-bar-model` |  | The real Select, sm and ghost, marked data-prompt-bar="model" on its root |
| `dictate` | `button` | `prompt-bar-dictate` |  | A <button> with the button recipe classes (ghost sm square muted, rounded unless the bar is a pill: its level bars must be its own flex item), data-slot="button", marked data-prompt-bar="dictate"; aria-pressed while dictating, when it keeps an accent tint; aria-label Start/Stop dictation and our tooltip |
| `bars` | `span` | `prompt-bar-bars` |  | Level bars shown while dictating, in place of the microphone |
| `bar` | `span` | `prompt-bar-bar` | repeats |  |
| `send` | `button` | `prompt-bar-send` |  | The real Button (primary sm square, rounded unless the bar is a pill), marked data-prompt-bar="send"; aria-label Send, or Stop generating while busy, and our tooltip |
| `positioner` | `div` | `prompt-bar-positioner` |  | Fixed over the composer, rendered in a portal; one per list. Carries data-scope="prompt-bar" data-part="positioner", so it stacks like every popup (base.css). Exposes --available-height |
| `list` | `div` | `prompt-bar-list` |  | The popup: the shared popup surface (`lib/popup.ts`). data-kind=source\|command; data-state=open\|closed; hidden while closed. Opened by typing, so it shows at once |
| `options` | `div` | `prompt-bar-options` |  | role=listbox; scrolls |
| `highlight` | `span` | `prompt-bar-highlight` |  | Shared gliding highlight layer (`glideLayer` of `lib/glide.ts`); glides under the pointer and the keyboard |
| `option` | `div` | `prompt-bar-option` | repeats | role=option; composes the shared option row (`lib/option.ts`, 36px through --option-height on the list: two runs of text). data-highlighted and aria-selected on the active option; hidden when filtered out |
| `option-icon` | `span` | `prompt-bar-option-icon` | optional | The shared option row's icon (`lib/option.ts`) |
| `option-label` | `span` | `prompt-bar-option-label` |  | The shared option row's text (`lib/option.ts`) |
| `option-description` | `span` | `prompt-bar-option-description` | optional | the shared option row's description (`lib/option.ts`) |
| `empty` | `div` | `prompt-bar-empty` |  | The real EmptyState (size row, start-aligned, 36px from the list --option-height), marked data-prompt-bar="empty"; shown when nothing matches |
| `footer` | `div` | `prompt-bar-footer` |  |  |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `shape` | `"pill" \| "rounded"` | `"rounded"` | Radius only. rounded: card radius. pill: fully round while it is one line, 24px once it holds attachments or more lines. |
| `value` | `string` | `""` | Bindable (React: `defaultValue` and `onValueChange`; Vue: `v-model:value`; Svelte: `bind:value`). The prompt text. |
| `placeholder` | `string` | `"Write a message…"` |  |
| `model` | `string` |  | Bindable (React: `defaultModel` and `onModelChange`; Vue: `v-model:model`; Svelte: `bind:model`). Value of the selected model. |
| `models` | `{ value: string; label: string; meta?: string }[]` |  | Model picker options (our select, sm and ghost). |
| `sources` | `{ value: string; label: string; description?: string; icon?: 'database' \| 'chart-bar' \| 'stack' \| 'globe' \| 'file-text' \| 'folder' \| 'link' \| 'users' \| 'envelope-simple' \| 'chat-circle' \| 'at' }[]` |  | Typing @ lists them (matched anywhere in the label); accepting inserts @Label. Also listed in the attach menu. |
| `commands` | `{ value: string; label: string? (default /value); description?: string }[]` |  | Typing / lists them (matched from the start); accepting inserts /value. |
| `attachments` | `{ name: string }[]` |  | Bindable (React: `defaultAttachments` and `onAttachmentsChange`; Vue: `v-model:attachments`; Svelte: `bind:attachments`). Attached files, shown as removable chips. Strings are accepted as names. |
| `dictating` | `boolean` | `false` | Bindable (React: `defaultDictating` and `onDictatingChange`; Vue: `v-model:dictating`; Svelte: `bind:dictating`).  |
| `busy` | `boolean` | `false` | The agent is working: the send button becomes a stop button and Enter does not send. |
| `aria-label` | `string` | `"Prompt"` | Accessible name of the textarea. |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `valueChange` | (value: string) |
| `modelChange` | (model: string) |
| `attachmentsChange` | (attachments: Attachment[]) |
| `dictatingChange` | (dictating: boolean) |
| `submit` | ({ value, model, attachments }) Enter or the send button; the bar then clears its text and attachments |
| `stop` | () the stop button while busy |
| `attach` | () 'Add photos & files' was chosen in the attach menu |

## States

`hover`, `press`, `focus-visible`, `focus-within`, `open`, `highlighted`, `busy`, `dictating`, `expanded`, `disabled`

## Keyboard and accessibility

Role: combobox (textarea) + listbox.

Keyboard:

- Typing @ or / after a space (or at the start) opens the matching list; the first option is active; focus stays in the textarea
- ArrowDown / ArrowUp move the active option (wrapping); the textarea announces it through aria-activedescendant
- Enter or Tab accept the active option and insert @Label or /command; Escape closes the list until the text changes
- With no list open: Enter sends, Shift+Enter inserts a newline; nothing sends while an IME composition is active or while busy
- Model picker: our select (Enter / Space / ArrowDown open, arrows move, Enter selects, Escape closes)
- Attach: our menu (Enter / Space / ArrowDown open, arrows move, Enter activates, Escape closes); choosing a source returns focus to the textarea
- Each button is a tab stop: attach, model, dictation (aria-pressed), send / stop

Notes:

- Icon-only buttons carry aria-label and our tooltip with the same text: Add attachments and sources, Start / Stop dictation, Send / Stop generating, Remove <file>.
- The suggestion lists open from typing, so they open and close without animation; the highlight glides between options for pointer and arrow-key moves alike.
- 16px text on coarse pointers so iOS does not zoom the page; enterkeyhint=send.

## Motion

- suggestion lists: the shared popup surface; opened by typing, so they show and hide at once (keyboard-instant). One highlight glides between options over duration.move, easing.out-strong, for pointer and arrow-key moves alike (the highlight is the one exception to keyboard-instant); a pressed option darkens to color.hover-2; "No matches" is the empty-state and fades in over duration.base
- buttons: our button's press (scale to motion.press-scale over duration.press) and colour over duration.fast
- composer: border colour and radius over duration.base (focus, pill growing past one line)
- layout switch: when the text needs the full width (or no longer does) the controls and the input travel to their new place (translate) and the composer's height follows, together over duration.move, easing.out-strong (FLIP, flipRow in prompt-bar.logic.ts). Typing triggers it, so it is not keyboard-instant; typing back and forth across the threshold retargets from where things are. Never on first paint; instant under reduced motion
- attachments: a tag pops in (fndn-pop-in, duration.popup) when it arrives
- send: one glimm sweep across the composer per send, over duration.sweep (1000ms) at an even ease-in-out pace, then a fade-out at duration.slow; skipped under reduced motion and when WebGL is missing
- dictation bars: loop while dictating; static under reduced motion

## Tokens

`duration.sweep`, `motion.popup-scale`, `color.surface`, `color.ink`, `color.ink-2`, `color.ink-3`, `color.line`, `color.line-strong`, `color.accent-tint`, `color.accent-ink`, `shadow.card`, `radius.window`, `radius.pill`, `text.2xs`, `text.sm`, `duration.base`, `duration.popup`, `easing.out-strong`

## Dependencies

- [Select](/components/select.md)
- [Menu](/components/menu.md)
- [Button](/components/button.md)
- [Tag](/components/tag.md)
- [Empty State](/components/empty-state.md)
- [Tooltip](/components/tooltip.md)

## Examples

### Ask about churn risk

React · `rounded.tsx`

```tsx
import type { ComponentProps } from "react";
import { PromptBar } from "@/components/ui/prompt-bar";

type Props = ComponentProps<typeof PromptBar>;

const models: Props["models"] = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
  { value: "atlas-reason", label: "Atlas Reason", meta: "Thinks longer" },
];

const sources: Props["sources"] = [
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
  { value: "tickets", label: "Support tickets", description: "Open and closed, last 90 days", icon: "chat-circle" },
  { value: "metrics", label: "Product metrics", description: "Bookings, activation, churn", icon: "chart-bar" },
  { value: "web", label: "Web search", description: "Public pages and news", icon: "globe" },
];

const commands: Props["commands"] = [
  { value: "summarize", description: "Summarize this conversation" },
  { value: "draft-email", description: "Write an email to a customer" },
  { value: "query", description: "Ask the data warehouse in SQL" },
  { value: "chart", description: "Chart the last result" },
  { value: "ticket", description: "Open a support ticket" },
];

export default function Rounded() {
  return (
    <PromptBar
      shape="rounded"
      defaultValue="Which accounts renewing in December show churn risk?"
      defaultModel="atlas-large"
      models={models}
      sources={sources}
      commands={commands}
      style={{ width: 420 }}
    />
  );
}
```

Vue · `rounded.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PromptBar, type PromptBarSource } from "@/components/ui/prompt-bar";

const value = ref("Which accounts renewing in December show churn risk?");

const model = ref("atlas-large");

const models = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
  { value: "atlas-reason", label: "Atlas Reason", meta: "Thinks longer" },
];

const sources: PromptBarSource[] = [
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
  { value: "tickets", label: "Support tickets", description: "Open and closed, last 90 days", icon: "chat-circle" },
  { value: "metrics", label: "Product metrics", description: "Bookings, activation, churn", icon: "chart-bar" },
  { value: "web", label: "Web search", description: "Public pages and news", icon: "globe" },
];

const commands = [
  { value: "summarize", description: "Summarize this conversation" },
  { value: "draft-email", description: "Write an email to a customer" },
  { value: "query", description: "Ask the data warehouse in SQL" },
  { value: "chart", description: "Chart the last result" },
  { value: "ticket", description: "Open a support ticket" },
];
</script>

<template>
  <PromptBar
    shape="rounded"
    v-model:value="value"
    v-model:model="model"
    :models="models"
    :sources="sources"
    :commands="commands"
    style="width: 420px"
  />
</template>
```

Svelte · `rounded.svelte`

```svelte
<script lang="ts">
  import { PromptBar, type PromptBarSource } from "$lib/components/ui/prompt-bar";

  let value = $state("Which accounts renewing in December show churn risk?");

  let model = $state("atlas-large");

  const models = [
    { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
    { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
    { value: "atlas-reason", label: "Atlas Reason", meta: "Thinks longer" },
  ];

  const sources: PromptBarSource[] = [
    { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
    { value: "tickets", label: "Support tickets", description: "Open and closed, last 90 days", icon: "chat-circle" },
    { value: "metrics", label: "Product metrics", description: "Bookings, activation, churn", icon: "chart-bar" },
    { value: "web", label: "Web search", description: "Public pages and news", icon: "globe" },
  ];

  const commands = [
    { value: "summarize", description: "Summarize this conversation" },
    { value: "draft-email", description: "Write an email to a customer" },
    { value: "query", description: "Ask the data warehouse in SQL" },
    { value: "chart", description: "Chart the last result" },
    { value: "ticket", description: "Open a support ticket" },
  ];
</script>

<PromptBar
  shape="rounded"
  bind:value={value}
  bind:model={model}
  models={models}
  sources={sources}
  commands={commands}
  style="width: 420px"
/>
```

### Stop an answer in progress

React · `pill.tsx`

```tsx
import type { ComponentProps } from "react";
import { PromptBar } from "@/components/ui/prompt-bar";

type Props = ComponentProps<typeof PromptBar>;

const models: Props["models"] = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
];

const sources: Props["sources"] = [
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
  { value: "tickets", label: "Support tickets", description: "Open and closed, last 90 days", icon: "chat-circle" },
  { value: "metrics", label: "Product metrics", description: "Bookings, activation, churn", icon: "chart-bar" },
];

export default function Pill() {
  return (
    <PromptBar
      shape="pill"
      busy
      defaultValue="Summarize this week's tickets from Juniper Health"
      defaultModel="atlas-small"
      models={models}
      sources={sources}
      style={{ width: 420 }}
    />
  );
}
```

Vue · `pill.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PromptBar, type PromptBarSource } from "@/components/ui/prompt-bar";

const value = ref("Summarize this week's tickets from Juniper Health");

const model = ref("atlas-small");

const models = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
];

const sources: PromptBarSource[] = [
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
  { value: "tickets", label: "Support tickets", description: "Open and closed, last 90 days", icon: "chat-circle" },
  { value: "metrics", label: "Product metrics", description: "Bookings, activation, churn", icon: "chart-bar" },
];
</script>

<template>
  <PromptBar
    shape="pill"
    busy
    v-model:value="value"
    v-model:model="model"
    :models="models"
    :sources="sources"
    style="width: 420px"
  />
</template>
```

Svelte · `pill.svelte`

```svelte
<script lang="ts">
  import { PromptBar, type PromptBarSource } from "$lib/components/ui/prompt-bar";

  let value = $state("Summarize this week's tickets from Juniper Health");

  let model = $state("atlas-small");

  const models = [
    { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
    { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
  ];

  const sources: PromptBarSource[] = [
    { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
    { value: "tickets", label: "Support tickets", description: "Open and closed, last 90 days", icon: "chat-circle" },
    { value: "metrics", label: "Product metrics", description: "Bookings, activation, churn", icon: "chart-bar" },
  ];
</script>

<PromptBar
  shape="pill"
  busy
  bind:value={value}
  bind:model={model}
  models={models}
  sources={sources}
  style="width: 420px"
/>
```

### Reconcile attached invoices

React · `with-attachments.tsx`

```tsx
import type { ComponentProps } from "react";
import { PromptBar } from "@/components/ui/prompt-bar";

type Props = ComponentProps<typeof PromptBar>;

const models: Props["models"] = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
];

const sources: Props["sources"] = [
  { value: "billing", label: "Billing", description: "Invoices, refunds and payouts", icon: "database" },
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
];

const attachments = ["INV-0117.pdf", "payouts-2024-10.csv", "kestrel-logistics-master-services-agreement.pdf"];

export default function WithAttachments() {
  return (
    <PromptBar
      shape="rounded"
      defaultValue="Check these invoices against the October payouts and flag any mismatch"
      defaultAttachments={attachments}
      defaultModel="atlas-large"
      models={models}
      sources={sources}
      style={{ width: 420 }}
    />
  );
}
```

Vue · `with-attachments.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PromptBar, type PromptBarSource } from "@/components/ui/prompt-bar";

const value = ref("Check these invoices against the October payouts and flag any mismatch");

const attachments = ref(["INV-0117.pdf", "payouts-2024-10.csv", "kestrel-logistics-master-services-agreement.pdf"]);

const model = ref("atlas-large");

const models = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
];

const sources: PromptBarSource[] = [
  { value: "billing", label: "Billing", description: "Invoices, refunds and payouts", icon: "database" },
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
];
</script>

<template>
  <PromptBar
    shape="rounded"
    v-model:value="value"
    v-model:attachments="attachments"
    v-model:model="model"
    :models="models"
    :sources="sources"
    style="width: 420px"
  />
</template>
```

Svelte · `with-attachments.svelte`

```svelte
<script lang="ts">
  import { PromptBar, type PromptBarSource } from "$lib/components/ui/prompt-bar";

  let value = $state("Check these invoices against the October payouts and flag any mismatch");

  let attachments = $state(["INV-0117.pdf", "payouts-2024-10.csv", "kestrel-logistics-master-services-agreement.pdf"]);

  let model = $state("atlas-large");

  const models = [
    { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
    { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
  ];

  const sources: PromptBarSource[] = [
    { value: "billing", label: "Billing", description: "Invoices, refunds and payouts", icon: "database" },
    { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
  ];
</script>

<PromptBar
  shape="rounded"
  bind:value={value}
  bind:attachments={attachments}
  bind:model={model}
  models={models}
  sources={sources}
  style="width: 420px"
/>
```

### Pick a slash command

React · `command-list-open.tsx`

```tsx
import type { ComponentProps } from "react";
import { PromptBar } from "@/components/ui/prompt-bar";

type Props = ComponentProps<typeof PromptBar>;

const models: Props["models"] = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
];

const sources: Props["sources"] = [
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
];

const commands: Props["commands"] = [
  { value: "summarize", description: "Summarize this conversation" },
  { value: "draft-email", description: "Write an email to a customer" },
  { value: "query", description: "Ask the data warehouse in SQL" },
  { value: "chart", description: "Chart the last result" },
  { value: "ticket", description: "Open a support ticket" },
];

/* the composer sits at the foot of the chat; the list opens upward into the room above it */
export default function CommandListOpen() {
  return (
    <div className="flex h-[300px] w-[420px] max-w-full flex-col justify-end">
      <PromptBar
        shape="rounded"
        defaultValue="/"
        defaultModel="atlas-large"
        models={models}
        sources={sources}
        commands={commands}
      />
    </div>
  );
}
```

Vue · `command-list-open.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PromptBar, type PromptBarSource } from "@/components/ui/prompt-bar";

const value = ref("/");

const model = ref("atlas-large");

const models = [
  { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
  { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
];

const sources: PromptBarSource[] = [
  { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
];

const commands = [
  { value: "summarize", description: "Summarize this conversation" },
  { value: "draft-email", description: "Write an email to a customer" },
  { value: "query", description: "Ask the data warehouse in SQL" },
  { value: "chart", description: "Chart the last result" },
  { value: "ticket", description: "Open a support ticket" },
];
</script>

<template>
  <!-- the composer sits at the foot of the chat; the list opens upward into the room above it -->
  <div class="flex h-[300px] w-[420px] max-w-full flex-col justify-end">
    <PromptBar
      shape="rounded"
      v-model:value="value"
      v-model:model="model"
      :models="models"
      :sources="sources"
      :commands="commands"
    />
  </div>
</template>
```

Svelte · `command-list-open.svelte`

```svelte
<script lang="ts">
  import { PromptBar, type PromptBarSource } from "$lib/components/ui/prompt-bar";

  let value = $state("/");

  let model = $state("atlas-large");

  const models = [
    { value: "atlas-large", label: "Atlas Large", meta: "Most capable" },
    { value: "atlas-small", label: "Atlas Small", meta: "Fastest" },
  ];

  const sources: PromptBarSource[] = [
    { value: "accounts", label: "Customer accounts", description: "1,284 workspaces, plans and MRR", icon: "users" },
  ];

  const commands = [
    { value: "summarize", description: "Summarize this conversation" },
    { value: "draft-email", description: "Write an email to a customer" },
    { value: "query", description: "Ask the data warehouse in SQL" },
    { value: "chart", description: "Chart the last result" },
    { value: "ticket", description: "Open a support ticket" },
  ];
</script>

<!-- the composer sits at the foot of the chat; the list opens upward into the room above it -->
<div class="flex h-[300px] w-[420px] max-w-full flex-col justify-end">
  <PromptBar
    shape="rounded"
    bind:value={value}
    bind:model={model}
    {models}
    {sources}
    {commands}
  />
</div>
```

## Recipe

`prompt-bar.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";
import { popup } from "../lib/popup";
import { option } from "../lib/option";
import { glideLayer } from "../lib/glide";

/* prompt-bar — the composer of an agent surface.
 * The model picker is our Select (sm, ghost), the attach menu our Menu, attach / dictate / send are
 * Buttons (sm, square; attach and dictate ghost + muted, send primary) whose shape follows the bar
 * (dictate is a <button> with the button recipe's classes: its level bars must be the button's own
 * flex item, and Button puts children in its label part); only their place in the row and the bar's own states are passed to them here (`attach`, `model`,
 * `dictate`, `send`). The @ and / lists live in a portal (fixed over the composer, placed by
 * placeList in prompt-suggest.ts) and compose the shared popup and option recipes and glideLayer (lib/glide.ts).
 *
 * Focus changes nothing on the composer: a field inside a composite surface shows the caret and
 * nothing else. The pill settles on its 24px radius as the text wraps: that
 * moves only while someone writes (focus inside), never on first paint.
 *
 * Attachments are the real Tag (neutral, with a remove button and its tooltip);
 * `attachment` is what the bar adds to each. Parts rendered by other components are marked
 * data-prompt-bar="attach|attach-trigger|dictate|send|attachment|attachment-remove|empty".
 * The keyframes of the dictation level bars are in base.css. */

const row = option();

export const promptBar = tv({
  slots: {
    base: "flex flex-col min-w-0 max-w-full",
    /* the bordered surface */
    composer: [
      "relative isolate flex flex-col gap-1.5 p-1.5",
      "border border-line rounded-window bg-surface shadow-card",
      "focus-within:motion-radius-base-out",
      /* while the row switches layout its height follows the controls (flipRow in prompt-bar.logic.ts
       * holds the old height, then sets the new one).
       * fndn-check-ok: the composer has to change height when the controls drop to a second row;
       * it moves with them, over duration.move */
      "data-[flip=to]:motion-size-move",
    ],
    /* the send sweep paints behind the content, inside the composer's shape */
    sweep: "absolute inset-0 -z-1 w-full h-full rounded-[inherit] pointer-events-none",
    attachments: "flex flex-wrap gap-1.5 max-h-24 overflow-y-auto overscroll-contain pt-0.5 px-0.5 pb-0",
    /* an attachment added while someone works in the bar (focus inside) pops in; one present at first
     * paint, or already there when focus comes back, does not move. The name stops at 144px. */
    attachment: [
      "motion-opacity-popup motion-transform-popup",
      "[[data-slot=prompt-bar-composer]:focus-within_&]:starting:opacity-0 [[data-slot=prompt-bar-composer]:focus-within_&]:starting:scale-popup",
      /* the name */
      "[&>[data-slot=tag-label]]:max-w-36",
    ],
    /* one line: [attach | input | model | dictate | send] */
    /* when the layout switches (expanded), flipRow puts each moved child back where it was
     * (data-flip="from": no transition) and lets it travel to its new place (data-flip="to":
     * translate over duration.move, out-strong). Typing triggers it, so it is not keyboard-instant;
     * a switch mid-way retargets from where things are. */
    row: [
      "grid grid-cols-[28px_minmax(0,1fr)_auto_28px_28px] [align-items:end] gap-x-1 gap-y-1.5",
      "[&>[data-flip=from]]:transition-none [&>[data-flip=to]]:motion-transform-move",
      "pointer-coarse:grid-cols-[36px_minmax(0,1fr)_auto_36px_36px]",
    ],
    attach: "col-start-1 row-start-1",
    attachTrigger: "pointer-coarse:size-9",
    /* grows with its content, then scrolls; a placeholder ends in an ellipsis instead of growing the
     * bar to two lines; under 16px iOS zooms into the field. Author text, the placeholder included
     * (unicode-bidi does not inherit into it), takes its direction from its own first letter, so
     * "Ask about this code…" keeps its ellipsis at the end on a right-to-left page */
    input: [
      "row-start-1 block w-full min-w-0 min-h-7 max-h-[100px] px-1 py-[5px]",
      "border-0 bg-transparent resize-none outline-none",
      "[font-family:inherit] [font-style:inherit] [font-weight:inherit] [font-stretch:inherit] [font-variant:inherit]",
      "text-sm leading-[18px] text-ink placeholder:text-ink-3",
      /* direction from the text, alignment from the page: an English placeholder on a right-to-left
       * page keeps its "…" at its end and still starts on the page's side (as names do) */
      "[unicode-bidi:plaintext] placeholder:[unicode-bidi:plaintext] [&:dir(ltr)]:text-left [&:dir(rtl)]:text-right",
      "wrap-anywhere overflow-y-auto overscroll-contain [field-sizing:content]",
      "placeholder-shown:overflow-hidden placeholder-shown:whitespace-nowrap placeholder-shown:text-ellipsis",
      "pointer-coarse:min-h-9 pointer-coarse:py-[7px] pointer-coarse:text-[16px] pointer-coarse:leading-[22px]",
    ],
    model: "col-start-3 row-start-1 min-w-0 [&_[data-slot=select-trigger]]:max-w-full",
    /* dictation keeps its accent tint while it listens */
    dictate: [
      "col-start-4 row-start-1 pointer-coarse:size-9",
      /* while it listens the icon gives way to the level bars */
      "[&[aria-pressed=true]>[data-slot=button-icon]]:hidden",
      "aria-pressed:bg-accent-tint aria-pressed:text-accent-ink aria-pressed:hover:bg-accent-tint aria-pressed:hover:text-accent-ink",
    ],
    /* level bars replace the microphone while listening (loop decision: reduced motion holds them
     * still, the pressed button and the placeholder already say it is listening) */
    bars: "hidden items-center gap-[2.5px] h-3.5 [[aria-pressed=true]_&]:inline-flex",
    /* their loop, each a beat behind the last (the keyframes are in base.css;
     * loops may name their own timing). Under reduced motion they hold still at three heights. */
    bar: [
      "w-[2.5px] h-full rounded-pill bg-current [transform:scaleY(0.4)] animate-[fndn-prompt-bar-level_900ms_ease_infinite]",
      "nth-2:animate-[fndn-prompt-bar-level_900ms_ease_150ms_infinite] nth-3:animate-[fndn-prompt-bar-level_900ms_ease_300ms_infinite]",
      "motion-reduce:animate-none motion-reduce:nth-2:[transform:scaleY(1)] motion-reduce:nth-3:[transform:scaleY(0.7)]",
    ],
    /* while there is nothing to send it is a grey square (not the faded disabled button) */
    send: [
      "col-start-5 row-start-1 pointer-coarse:size-9",
      "disabled:bg-line-strong disabled:text-ink-2 disabled:shadow-none disabled:opacity-100",
    ],
    /* suggestion lists: the shared popup surface. They open from typing, so they show at once. The
     * positioner is not a Zag part: it carries data-scope + data-part="positioner" for the stacking. */
    positioner: "",
    /* rows carry two runs of text: the shared option row's lg size (the empty row takes it too) */
    list: [popup(), "flex flex-col [--option-height:36px]"],
    /* the listbox scrolls inside the popup, above the footer */
    options: "relative min-h-0 overflow-y-auto overscroll-contain outline-none",
    /* the one gliding highlight; the popup's 4px is the inset */
    highlight: [glideLayer, "inset-x-0"],
    option: row.base(),
    optionIcon: row.icon(),
    optionLabel: row.text(),
    optionDescription: row.description(),
    footer: "shrink-0 mt-1 pt-1.5 px-2 pb-1 border-t border-line text-2xs text-ink-2",
  },
  variants: {
    /* radius only. pill: fully round while it is one line; once it holds more, 24px */
    shape: {
      rounded: {},
      pill: {
        composer: "rounded-pill has-[[data-slot=prompt-bar-attachments]]:rounded-[24px]",
        attachments: "px-1",
      },
    },
    /* the text wraps or has a newline: the input takes the first row, the controls the second */
    expanded: {
      false: { input: "col-start-2" },
      true: {
        row: "grid-cols-[28px_auto_minmax(0,1fr)_28px_28px] pointer-coarse:grid-cols-[36px_auto_minmax(0,1fr)_36px_36px]",
        input: "col-[1/-1]",
        attach: "row-start-2",
        model: "col-start-2 row-start-2 [justify-self:start]",
        dictate: "row-start-2",
        send: "row-start-2",
      },
    },
  },
  compoundVariants: [{ shape: "pill", expanded: true, class: { composer: "rounded-[24px]" } }],
  defaultVariants: { shape: "rounded", expanded: false },
});

export type PromptBarRecipeProps = VariantProps<typeof promptBar>;
```
