Skip to content
Uxelith
Prov1.0.0AI & Agents

Prompt Composer

The box people type into when they talk to your AI: @mentions, /commands, files by drop or paste with upload progress, long pastes as attachments, send and stop, and Enter that is safe for Japanese and Chinese.

Installs with Uxelith ProHow
Licence
Pro
Packages
9
Updated
12 Nov 2026
Live

Installation

Usage

example.tsx
"use client"

import { useState } from "react"
import { PromptComposer, type PromptSubmission } from "@/components/prompt-composer"

export function AskBox() {
  const [busy, setBusy] = useState(false)
  const [controller, setController] = useState<AbortController | null>(null)

  async function send(message: PromptSubmission) {
    const abort = new AbortController()
    setController(abort)
    setBusy(true)
    try {
      // Your route reads message.text, message.command, message.references and message.attachments.
      await fetch("/api/chat", { method: "POST", body: JSON.stringify({ ...message, attachments: message.attachments.map((a) => a.url ?? a.name) }), signal: abort.signal })
    } finally {
      setBusy(false)
    }
  }

  return (
    <PromptComposer
      busy={busy}
      onStop={() => controller?.abort()}
      onSubmit={send}
      references={[
        { id: "u1", label: "Elena Novak", kind: "person", hint: "Design" },
        { id: "f1", label: "Q4 report.pdf", kind: "file", hint: "PDF" },
      ]}
      commands={[{ name: "summarize", description: "Summarise the attached files" }]}
      toggles={[{ id: "search", label: "Search", icon: "search" }]}
      onUpload={async (file, { signal }) => {
        const body = new FormData()
        body.append("file", file)
        const response = await fetch("/api/upload", { method: "POST", body, signal })
        const { url } = (await response.json()) as { url: string }
        return url
      }}
      draftKey="ask-box-draft"
    />
  )
}

Props

PropTypeDefaultDescription
onSubmit(message) => void | Promise<void>—Called on send with { text, json, command, references, attachments, toggles, model }. Return a promise: if it rejects, the message comes back into the box.
busy / onStopboolean / () => voidfalseWhile an answer is on its way, the send button becomes Stop; Escape stops too.
referencesPromptReference[] | (query) => PromptReference[] | Promise—What "@" offers: { id, label, kind?, hint?, group?, color?, avatar? }. People and files have their own look. Pass a function to search your own data.
commandsPromptCommand[]—What "/" offers at the start of a message: { name, description? }.
onUpload(file, { signal, onProgress }) => Promise<string | void>—Uploads an attached file and resolves to its URL, with progress. Sending waits for uploads. Without it, files are sent with the message as they are.
attachments / accept / maxFileSize / maxFilesboolean / string / number / numbertrue / — / 20 MB / 10Attaching by button, drop and paste, and its limits.
pasteAsAttachmentnumber1200A paste longer than this many characters becomes an attachment you can open; 0 turns it off.
maxLengthnumber—A character limit: a counter appears near it and sending stops above it.
toggles / onToggleChangePromptToggle[]—Buttons such as Search or Think: { id, label, icon?, defaultPressed? }. Their state arrives with each message.
models / model / defaultModel / onModelChangePromptModel[] / string—A model picker: { id, label, description? }.
submitKey / hint"enter" | "mod-enter" / boolean"enter" / trueWhich keys send, and the line below the box that says so and lets people switch.
draftKeystring—Keeps the unsent message in localStorage under this key.
refPromptComposerHandle—focus(), clear() and setContent(text or JSON), e.g. for suggested prompts.
defaultValue / placeholder / disabled / labelstring | JSONContent / string / boolean / string— / "Ask anything…" / false / "Message"Starting text, the empty-box hint, turning it off, and the accessible name.

Accessibility

  • The box is a named multi-line text box; the "@" and "/" lists follow the combobox pattern, so focus stays in the text, the arrow keys move, Enter or Tab chooses and Escape closes.
  • Enter never sends while a Japanese, Chinese or Korean word is still being composed; people who want Enter for new lines can switch to Cmd or Ctrl Enter from the hint.
  • Attachments are a labelled list; uploads report progress, each file has a named remove button, and sending says why it is waiting.
  • Toggles are pressed buttons, the model picker is a menu of radio items with arrow keys, and Stop is a real button as well as Escape.
  • Sending, stopping, attaching, removing and failures are announced politely, and a failed send puts the message back.
  • Under prefers-reduced-motion nothing eases.

Changelog

  1. v1.0.0Latest

    First release.

More in AI & Agents

All 9 in AI & Agents
  • AI & AgentsPro

    Agent Run Monitor

    A live view of AI agents working together: each agent's steps on one timeline, cost against a budget, tokens, every step's input and output, failures, and an approval card when a step needs a person.

  • AI & AgentsPro

    Approval Card

    The moment an AI agent asks before acting: what it wants to do, why, and exactly what will happen. Approve is held for a beat so it's never an accident; Deny is one press. Then it folds into a one-line record.

  • AI & AgentsPro

    Artifact Canvas

    The workspace beside an AI chat: what the model writes opens next to the conversation, streams in line by line, keeps every version and shows what changed down to the word. Preview, read, ask about code, download.