Компоненты
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Calendar
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Date Picker
- Dialog
- DrawerNew
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Meter
- Number Field
- OTP FieldNew
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
AI Components
- AI Components
- Chat Conversation
- Chat Message
- Chat Response
- Chat Suggestion
- Chat Prompt Input
- Chat Attachments
- Chat Code Block
- Chat Image
- Chat Inline Citation
- Chat Reasoning
- Chat Sources
- Chat Actions
- Chat Context
- Chat Loader
- Chat Task
- Chat Tool
- Chat Web Preview
- Chat Snippet
- Chat Terminal
- Chat Stack Trace
- Chat Test Results
- Chat File Tree
- Chat Environment Variables
- Chat Audio Player
- Chat Transcription
- Chat Speech Input
- Chat Mic Selector
- Chat Voice Selector
- Chat Agent
- Chat Persona
- Chat Connection
- Chat Queue
- Chat Checkpoint
- Chat Confirmation
- Chat Artifact
- Chat JSX Preview
- Chat Schema Display
- Chat Package Info
- Chat Commit
- Chat Plan
- Chat Panel
- Chat Open In Chat
- Chat Sandbox
- Chat Model Selector
- Chat Canvas
- Chat Node
- Chat Edge
Resources
Chat Prompt Input
Форма ввода с auto-resize textarea, Enter/Shift+Enter и состояниями отправки.
"use client";
import { MicIcon, PaperclipIcon } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import {
ChatPromptInput,
ChatPromptInputSubmit,
ChatPromptInputTextarea,
ChatPromptInputToolbar,
ChatPromptInputTools,
} from "@/components/ui/chat-prompt-input";
export default function Particle() {
const [sent, setSent] = useState<string | null>(null);
return (
<div className="flex w-full max-w-xl flex-col gap-3 p-4">
<ChatPromptInput onMessageSend={setSent}>
<ChatPromptInputTextarea placeholder="Спроси что-нибудь…" />
<ChatPromptInputToolbar>
<ChatPromptInputTools>
<Button aria-label="Attach" size="icon-sm" variant="ghost">
<PaperclipIcon aria-hidden="true" />
</Button>
<Button aria-label="Voice" size="icon-sm" variant="ghost">
<MicIcon aria-hidden="true" />
</Button>
</ChatPromptInputTools>
<ChatPromptInputSubmit status="ready" />
</ChatPromptInputToolbar>
</ChatPromptInput>
{sent ? (
<p className="text-muted-foreground text-sm">
Отправлено:{" "}
<span className="font-medium text-foreground">{sent}</span>
</p>
) : null}
</div>
);
}
Installation
pnpm dlx shadcn@latest add @jenny/chat-prompt-input
Usage
import {
ChatPromptInput,
ChatPromptInputSubmit,
ChatPromptInputTextarea,
ChatPromptInputToolbar,
ChatPromptInputTools,
} from "@/components/ui/chat-prompt-input";
<ChatPromptInput onMessageSend={(text) => sendMessage(text)}>
<ChatPromptInputTextarea placeholder="Спроси что-нибудь…" />
<ChatPromptInputToolbar>
<ChatPromptInputTools>
<Button aria-label="Attach" size="icon-sm" variant="ghost">
<PaperclipIcon />
</Button>
</ChatPromptInputTools>
<ChatPromptInputSubmit status="ready" />
</ChatPromptInputToolbar>
</ChatPromptInput>Поведение
- Enter — submit формы.
- Shift + Enter — новая строка.
- Textarea авто-растёт от
minHeight=48доmaxHeight=200(настраивается props). - После submit инпут очищается и получает фокус обратно.
API
| Component | Описание |
|---|---|
ChatPromptInput | <form> с обёрткой стилей. Принимает onMessageSend: (text: string) => void. |
ChatPromptInputTextarea | Авто-растущий textarea. Принимает minHeight, maxHeight. |
ChatPromptInputToolbar | Layout-строка под textarea (для tools + submit). |
ChatPromptInputTools | Группа кнопок слева (attach, mic, model selector, …). |
ChatPromptInputSubmit | Submit-кнопка. Принимает status: 'ready' | 'submitted' | 'streaming' | 'error' — меняет иконку (arrow ↔ stop). |
On This Page