Prompt Input
A composable AI prompt composer with attachments, toolbar actions, send states, queued prompts, and drag-and-drop support.
Usage
"use client";
import { Fragment, useCallback, useEffect, useRef, useState } from "react";
import { ArrowUp01Icon, Attachment01Icon } from "@thenamespace/uikit/icons";Use PromptInput as the message composer for chat and agent interfaces.
Secondary
"use client";
import { Fragment, useCallback, useEffect, useRef, useState } from "react";
import { ArrowUp01Icon, Attachment01Icon } from "@thenamespace/uikit/icons";Use the secondary variant when the composer sits on a default surface.
Inline
"use client";
import { Fragment, useCallback, useEffect, useRef, useState } from "react";
import { ArrowUp01Icon, Attachment01Icon } from "@thenamespace/uikit/icons";Use the inline layout when attachment, input, and send controls should stay aligned in one row while the textarea autosizes as users type or add line breaks.
Compact
"use client";
import { Fragment, useCallback, useEffect, useRef, useState } from "react";
import { ArrowUp01Icon, Attachment01Icon } from "@thenamespace/uikit/icons";Use the compact layout when the composer should start as a single-row pill and switch to the stacked composer once text wraps or attachments are added.
Review Composer
"use client";
import { useState } from "react";
import {Compose PromptInput with workflow controls to build compact agent surfaces such as review follow-ups and commit actions.
With Suggestions
Build something useful with Namespace UIKit AI
Start with a prompt, add files, or pick a suggestion to shape the first response.
"use client";
import { useState } from "react";
import {Compose PromptInput with PromptSuggestion to create a landing-style composer with quick-start prompts.
Run State
"use client";
import { useCallback, useEffect, useRef, useState } from "react";
import { PromptInput } from "@thenamespace/uikit";Prompt input supports submitted, streaming, ready, and error states for send/stop behavior.
Queue
Review the attached mockups before implementing the landing page updates.
Add dark mode support to the settings page.
Refactor the queue item layout to match Codex.
1 attachment
"use client";
import { useCallback, useEffect, useRef, useState } from "react";
import {Use PromptInput.Queue to show queued follow-up prompts in a compact card above the composer shell. Place it as a sibling of PromptInput.Shell inside PromptInput. Keep queue rows text-only for a clean surface — store attachments in your queue model and restore them to PromptInput.Attachments when the user edits a queued prompt.
With Attachments
Pair PromptInput with ChatAttachmentInput.Dropzone to accept dropped files. While a file is dragged over the shell, the composer shows a dotted accent border.
Anatomy
import { PromptInput } from "@thenamespace/uikit";
<PromptInput
value={value}
layout="stacked"
onSubmit={send}
onValueChange={setValue}
>
<PromptInput.Queue>
<PromptInput.Queue.List values={queuedPrompts} onReorder={setQueuedPrompts}>
{queuedPrompts.map((prompt) => (
<PromptInput.Queue.Item key={prompt.id} value={prompt}>
<PromptInput.Queue.Item.Handle />
<PromptInput.Queue.Item.Body>
<PromptInput.Queue.Item.Icon />
<PromptInput.Queue.Item.Content>
Queued prompt text
</PromptInput.Queue.Item.Content>
</PromptInput.Queue.Item.Body>
<PromptInput.Queue.Item.Actions>
<PromptInput.Queue.Item.Remove />
<PromptInput.Queue.Item.More />
</PromptInput.Queue.Item.Actions>
</PromptInput.Queue.Item>
))}
</PromptInput.Queue.List>
</PromptInput.Queue>
<PromptInput.Shell>
<PromptInput.Content>
<PromptInput.TextArea placeholder="What do you want to know?" />
</PromptInput.Content>
<PromptInput.Toolbar>
<PromptInput.ToolbarStart>
<PromptInput.Action aria-label="Attach file">...</PromptInput.Action>
</PromptInput.ToolbarStart>
<PromptInput.ToolbarEnd>
<PromptInput.Send />
</PromptInput.ToolbarEnd>
</PromptInput.Toolbar>
</PromptInput.Shell>
<PromptInput.Footer>
AI can make mistakes. Check important info.
</PromptInput.Footer>
</PromptInput>;CSS Classes
.prompt-input- Root state wrapper.prompt-input__shell- Composer surface.prompt-input__content- Textarea and attachment content area.prompt-input__attachments- Attachment preview row.prompt-input__textarea- Text area.prompt-input__toolbar- Absolute toolbar row.prompt-input__toolbar-start- Leading toolbar actions.prompt-input__toolbar-end- Trailing toolbar actions.prompt-input__footer- Disclaimer/footer text.prompt-input__send- Send/stop button.prompt-input__queue- Queued prompts container.prompt-input__queue-list- Scrollable queue list.prompt-input__queue-item- Single queued prompt row.prompt-input__queue-item-handle- Drag handle (presentational).prompt-input__queue-item-icon- Leading queue item icon.prompt-input__queue-item-body- Main queue row content stack.prompt-input__queue-item-content- Clamped prompt text (2 lines).prompt-input__queue-item-description- Secondary queue item text.prompt-input__queue-item-actions- Trailing row actions.prompt-input__queue-item-attachments- Attachment preview row inside a queue item.prompt-input__queue-item-attachments-overflow- Hidden attachment count label
API Reference
PromptInput
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | internal | Controlled input value |
onValueChange | (value: string) => void | - | Called when the text changes |
onSubmit | () => void | - | Called when submit is requested |
onStop | () => void | - | Called by the send button in stoppable states |
status | 'ready' | 'submitted' | 'streaming' | 'error' | 'ready' | Composer run state |
isDisabled | boolean | false | Disable composer controls |
lockInputOnRun | boolean | true | Disable textarea while submitted/streaming |
maxHeight | number | string | 240 | Autosize textarea max height |
size | 'sm' | 'md' | 'lg' | 'md' | Composer size |
variant | 'primary' | 'secondary' | 'primary' | Surface styling variant |
layout | 'stacked' | 'compact' | 'inline' | 'stacked' | Composer layout and toolbar placement |
PromptInput.TextArea
Extends Namespace UIKit TextArea props.
| Prop | Type | Default | Description |
|---|---|---|---|
disableAutosize | boolean | false | Disable automatic height adjustment |
PromptInput.Action
Extends Namespace UIKit Button props.
| Prop | Type | Default | Description |
|---|---|---|---|
tooltip | ReactNode | - | Optional tooltip content |
PromptInput.Send
Extends Namespace UIKit Button props. Uses the current prompt status to render send, loading, stop, or error icons.
PromptInput.Shell, Content, Attachments, Toolbar, ToolbarStart, ToolbarEnd, Footer
Layout slots for composing the prompt input. Each slot supports the corresponding native element props.
PromptInput.Queue
| Prop | Type | Default | Description |
|---|---|---|---|
actionsVisibility | 'always' | 'hover' | 'hover' | When queue row actions are visible |
PromptInput.Queue.List
| Prop | Type | Default | Description |
|---|---|---|---|
values | T[] | - | Controlled queue values. Pass with onReorder to enable Motion reordering. |
onReorder | (values: T[]) => void | - | Called when items are reordered via drag and drop. |
axis | 'x' | 'y' | 'y' | Reorder axis when drag and drop is enabled. |
PromptInput.Queue.Item
| Prop | Type | Default | Description |
|---|---|---|---|
value | T | - | Item value from values. Required when reordering is enabled. |
PromptInput.Queue.Item.Body, Handle, Icon, Content, Description, Attachments, Actions
Presentational slots for queue row structure. Wrap Icon and Content in Body so the icon sits beside the clamped text and stays vertically centered. Content clamps text to two lines with an ellipsis.
PromptInput.Queue.Item.AttachmentsOverflow
Optional overflow label when you choose to render attachment previews inside a queue row.
| Prop | Type | Default | Description |
|---|---|---|---|
hiddenCount | number | - | Number of attachments hidden beyond the visible previews |
noun | string | 'files' | Noun used in the overflow label |
PromptInput.Queue.Item.Remove, More, Action
Action buttons for queue rows. Remove and More include default labels and icons. Extend Namespace UIKit Button props.