Luca Perullo
Components

Component

LiveNew

AI Prompt Input

La forma Claude/ChatGPT 2026 — multi-line auto-grow, Enter invia / Shift+Enter va a capo, slash menu sopra l'input quando inizi con "/", file picker, send button che diventa stop quando busy.

AIChatInputFormClient
Open in ClaudeSorgente

Esempio01

ai-prompt-input.tsx

Note Auto-grow è cap-pato a maxHeight (default 220px) e poi diventa scroll interno. Le slash commands accettano qualsiasi stringa di insert (non deve iniziare con /). Send è disabilitato finché value e attachments sono vuoti.

Prompt LLM02

Incolla in Claude o ChatGPT per generare la tua variante. Include il contesto del brand, i token e i vincoli del progetto.

Prompt · ai-prompt-input
Open in Claude
Sei un senior frontend engineer. Stai lavorando su un sito Next.js 16 + React 19 + Tailwind v4 in italiano, look chanhdai-inspired: colonna stretta 672px, Geist Sans + Geist Mono, hairline 1px, divisori a stripe diagonale, palette zinc.

Token CSS disponibili: --bg, --bg-alt, --fg, --fg-muted, --fg-soft, --border, --border-strong, --accent. Usa SEMPRE queste variabili tramite le utility tailwind generate (bg-bg, text-fg-muted, border-border, ecc.). Helper "cn" da "@/lib/utils". Niente librerie UI extra: solo lucide-react e tailwind-merge.

Genera un componente <AiPromptInput> per chat AI moderna (forma Claude/ChatGPT).
Type:
- AiPromptInputAttachment = { id; name; size? }
- AiSlashCommand = { id; label; insert; hint? }
Props:
- placeholder?: string.
- initialValue?: string.
- busy?: boolean.
- onSubmit: (value: string, attachments: AiPromptInputAttachment[]) => void.
- onStop?: () => void.
- slashCommands?: AiSlashCommand[].
- allowAttach?: boolean (default true).
- leftToolbar?: ReactNode.
- maxHeight?: number (default 220).
- className?: string.

Implementazione:
- "use client", textarea auto-grow (height auto → scrollHeight cap maxHeight).
- Enter (no shift) invia, Shift+Enter newline.
- Slash menu: visibile se value.startsWith("/") && commands.length > 0; ArrowUp/Down nav, Tab/Enter inserisce, Esc chiude.
- Attachments row sopra il textarea quando ci sono, ognuna con button X.
- File picker hidden + button Paperclip.
- Footer con kbd hint (↵ invia · ⇧↵ a capo).
- Send button: ArrowUp icon. Quando busy && onStop: button morph a Square fill (interrompi).

Output: file completo src/components/ai-prompt-input.tsx.

Uso tipico03

tsx
<AiPromptInput
  busy={isStreaming}
  onSubmit={(value, attachments) => sendToAgent(value, attachments)}
  onStop={() => abort()}
  slashCommands={[{ id, label: "/help", insert: "/help", hint }]}
/>

Dipendenze04

npm
  • lucide-react
  • tailwind-merge
  • clsx
Interno
  • @/lib/utils#cn

Ti è servito? Dimmelo, oppure proponi il prossimo componente.