Features
Libraries
A one-line chat composer that turns @mentions and /commands into pills and hands the message to the host as a payload.
Installation#
bash
pnpm dlx shadcn@latest add @zui/chat-inputUsage#
tsx
import type { ChatMessagePayload } from '@zeroxsolutions/editor-core/composer/index';
import { ChatInput } from '@/components/editor/composer/chat-input';tsx
function Composer({ send }: { send: (payload: ChatMessagePayload) => void }) {
return <ChatInput placeholder="Message the group..." onSubmit={send} />;
}Enter sends and clears the input, and Shift+Enter starts a new line. The payload carries the flattened text, the committed tokens grouped by kind, and the one-block doc that ChatMessageView draws, in chat-message-view.tsx.
API reference#
ChatInput#
| Prop | Type | Default |
|---|---|---|
triggers | ComposerTrigger[] | @ and / |
placeholder | string | 'Message...' |
onSubmit | (payload: ChatMessagePayload) => void | - |
onReady | (editor: IEditor) => void | - |
className | string | - |
Give triggers a stable array: the editor is built from it once, on mount.