Chat Input
simple-ai/chat-inputFreeComponent
A chat input component with mention support and automatic height adjustment.
Live preview
live · rendered by the registry
Rendered by simple-ai on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://simple-ai.dev/r/chat-input.jsonSource
1"use client";23import { Extension } from "@tiptap/core";4import { Mention as MentionExtension } from "@tiptap/extension-mention";5import Placeholder from "@tiptap/extension-placeholder";6import type { Editor, JSONContent } from "@tiptap/react";7import { EditorContent, ReactRenderer, useEditor } from "@tiptap/react";8import StarterKit from "@tiptap/starter-kit";9import type { SuggestionProps } from "@tiptap/suggestion";10import { ArrowUpIcon, Loader2, PlusIcon } from "lucide-react";1112import {13 type ComponentProps,14 createContext,15 forwardRef,16 type ReactNode,17 useCallback,18 useContext,19 useEffect,20 useImperativeHandle,21 useMemo,22 useRef,23 useState,24} from "react";25import tippy, { type Instance } from "tippy.js";26import { Button } from "@/components/ui/button";27import {28 DropdownMenu,29 DropdownMenuContent,30 DropdownMenuItem,31 DropdownMenuTrigger,32} from "@/components/ui/dropdown-menu";33import {34 InputGroup,35 InputGroupAddon,36 InputGroupButton,37 InputGroupText,38} from "@/components/ui/input-group";39import { cn } from "@/lib/utils";4041export type ChatInputValue = JSONContent;4243export type BaseMentionItem = {44 id: string;45 name: string;46};4748type MentionConfig<T extends BaseMentionItem = BaseMentionItem> = {49 type: string;50 trigger: string; // e.g., '@' or '/'51 items: T[];52 renderItem?: (item: T, isSelected: boolean) => ReactNode;53 editorMentionClass?: string;54};5556export function createMentionConfig<57 T extends BaseMentionItem = BaseMentionItem,58>(config: MentionConfig<T>): MentionConfig<T> {59 return config;60}6162type ChatInputContextType = {63 // biome-ignore lint/suspicious/noExplicitAny: Needs to accept configs with different item types64 mentionConfigs: MentionConfig<any>[];65 // biome-ignore lint/suspicious/noExplicitAny: Needs to accept configs with different item types66 addMentionConfig: (config: MentionConfig<any>) => void;67 onSubmit: () => void;68 onStop?: () => void;69 isStreaming: boolean;70 disabled: boolean;71 value?: ChatInputValue;72 onChange?: (value: ChatInputValue) => void;73 editor: Editor | null;74 setEditor: (editor: Editor | null) => void;75};7677const ChatInputContext = createContext<ChatInputContextType>({78 mentionConfigs: [],79 addMentionConfig: () => {},80 onSubmit: () => {},81 onStop: undefined,82 isStreaming: false,83 disabled: false,84 value: undefined,85 onChange: undefined,86 editor: null,87 setEditor: () => {},88});8990export function ChatInput({91 children,92 className,93 onSubmit,94 isStreaming = false,95 onStop,96 disabled = false,97 value,98 onChange,99 ...props100// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from simple-ai
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| base-handlebase-handle | simple-ai | Components | Free | 1 dep | |
| base-nodebase-node | simple-ai | Components | Free | no deps | |
| Chat Messagechat-message | simple-ai | Components | Free | no deps | |
| Chat Message Areachat-message-area | simple-ai | Components | Free | 1 dep | |
| Chat Suggestionschat-suggestions | simple-ai | Components | Free | no deps | |
| Editable Handleeditable-handle | simple-ai | Components | Free | 1 dep | |
| Generate Text Nodegenerate-text-node | simple-ai | Components | Free | 1 dep | |
| JSON Schema Editorjson-schema-editor | simple-ai | Components | Free | 1 dep |
