# Prompt Composer (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-prompt-composer` · version 1.0.0 · component · pro (Pro)
- category: AI interfaces
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-prompt-composer`
- npm dependencies: none
- registry dependencies: utils, @beautiful-ui/lumen-button, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-prompt-composer
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Where a person writes to a model: a box that grows with the text, Enter to send and Shift+Enter for a new line, Send that becomes Stop while a reply runs, and files by the clip button, drag and drop or paste into an attachments slot.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: none beyond React.
- Files: `components/ui/lumen/controls/prompt-composer.tsx`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-button`, `lumen-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `PromptComposer`, and every exported type.
- CSS: the install merges this item's rules (the registry `css` field) into your global stylesheet, in `@layer components`, and adds the lumen foundation (tokens, keyframes, motion levels) once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--lumen-*` custom properties (`--lumen-accent`, `--lumen-accent-foreground`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-chart-accent`, `--lumen-chart-accent-foreground`, `--lumen-chart-accent-text`, `--lumen-focus`, `--lumen-good`, `--lumen-good-text`, `--lumen-hairline`, `--lumen-ink`, `--lumen-muted-ink`, `--lumen-series-1`, `--lumen-series-2`, `--lumen-series-3`, `--lumen-series-4`, `--lumen-series-5`, `--lumen-series-6`, `--lumen-warn`, `--lumen-warn-text`); this item's CSS also reads `--lumen-font-sans`, `--lumen-radius-k`. Never add Tailwind colour classes inside the component.

```tsx
import { PromptComposer } from "@/components/ui/lumen/controls/prompt-composer";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `PromptComposer` | — | The form. Inside: prompt-composer-attachments, -input, -footer, -attach, -send and -stop. |

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `GlassSoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/glass-sound.json`, import from `@/components/beautiful-ui/glass-sound`); `GlassSoundToggle` is its mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/lumen/controls/prompt-composer.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- chat input, prompt input, AI composer, message box, send and stop button, attach files to a prompt, Lumen
- The input of an AI chat or assistant
- Any message box that sends on Enter and can stop a running reply

### Not when
- Mentioning people in a note: use Mention Composer
- A plain multi-line form field: use Textarea

## Mistakes
- Keep running true until the reply finishes, so a second Enter can't send twice
- onFiles gives File objects: upload them yourself and show progress in the attachments slot

## Usage

```tsx
"use client";

import * as React from "react";
import { PromptComposer } from "@/components/ui/lumen/controls/prompt-composer";
import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentTitle } from "@/components/ui/lumen/attachment";

export function AskBox({ send, stop, running }: { send: (text: string, files: File[]) => void; stop: () => void; running: boolean }) {
  const [files, setFiles] = React.useState<File[]>([]);
  return (
    <PromptComposer
      running={running}
      onStop={stop}
      hint
      onSubmit={({ text }) => {
        send(text, files);
        setFiles([]);
      }}
      onFiles={(added) => setFiles((all) => [...all, ...added])}
      accept="image/*,.pdf,.csv"
      attachments={
        files.length > 0 &&
        files.map((f) => (
          <Attachment key={f.name} size="sm">
            <AttachmentContent>
              <AttachmentTitle>{f.name}</AttachmentTitle>
            </AttachmentContent>
            <AttachmentActions>
              <AttachmentAction icon="close" aria-label={`Remove ${f.name}`} onClick={() => setFiles((all) => all.filter((x) => x !== f))} />
            </AttachmentActions>
          </Attachment>
        ))
      }
    />
  );
}
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `value / defaultValue / onValueChange` | `string` |  | Controlled or not. Uncontrolled text clears after sending. |
| `onSubmit` | `({ text }) => void \| boolean` |  | Send. Return false to keep the text (a validation failed). |
| `running / onStop` | `boolean / () => void` |  | A reply is running: Send becomes Stop with a thin arc around it, Escape stops, Enter no longer sends. |
| `onFiles / accept / multiple` | `(files: File[]) => void / string / boolean` | `— / — / true` | Shows the clip button; files also arrive by drop and paste. Show them in attachments. |
| `attachments` | `ReactNode` |  | Above the text: the files waiting to go (Lumen Attachment fits). |
| `tools` | `ReactNode` |  | Your controls in the footer (a model picker, a mode toggle). |
| `submitOn` | `"enter" \| "mod-enter"` | `"enter"` | mod-enter: Cmd/Ctrl+Enter sends and Enter is a new line (long-form prompts). |
| `hint` | `boolean` | `false` | Show the keyboard hint in the footer (hidden on narrow screens). |
| `canSubmitEmpty` | `boolean` | `false` | Allow sending with no text (attachments alone). |
| `maxRows` | `number` | `8` | Rows the box grows to before it scrolls. |
| `labels` | `Partial<PromptComposerLabels>` |  | input (the accessible name), send, stop, attach, drop, hint(mode, mac). |
| `textareaRef` | `Ref<HTMLTextAreaElement>` |  | The textarea, to focus it from elsewhere. |

Full docs: https://beautiful-ui.dev/components/lumen-prompt-composer

## Customising
- Colours: set the `--lumen-*` tokens on `:root`, or on a container with the `lumen-scope` class to retheme one area. Add the `lumen-inherit` class to follow your shadcn palette instead (`--chart-N`, `--destructive`).
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Enter | Send (or a new line with submitOn="mod-enter") |
| Shift+Enter | New line |
| Cmd/Ctrl+Enter | Send, with submitOn="mod-enter" |
| Escape | Stop the running reply |

## Motion inventory

| Interaction | What moves |
|---|---|
| Focus | The ring lights and a filament draws along the lower edge, as on Textarea |
| Running | A thin arc circles Stop; reduced motion shows a still ring |

## Accessibility contract (preserve when editing)
- The textarea has a real accessible name (labels.input), not just a placeholder, and its send shortcut in aria-keyshortcuts
- Send, Stop and Attach are named buttons; Send is disabled (but focusable) while there's nothing to send
- An input method's Enter (composing Japanese or Chinese) never sends

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-prompt-composer
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Built on shadcn/ui (https://ui.shadcn.com)

The lumen foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/lumen-foundation.json.
