AI Chat Interface

Pro

A complete AI chat interface for React: streaming replies, web search with cited sources, stop, retry and a model picker.

aichatchatbotllmstreamingweb searchcitationsvoice
AI Chat Interface component preview

Overview

AI Chat Interface is a React and Tailwind CSS chatbot UI that streams replies, searches the web and cites its sources, in Next.js or any React app. Your respond function yields reasoning, search, source and text chunks, and the chat buffers them into whole words that fade in on a steady beat. Stop keeps the partial answer, retry saves versions to page through, and the composer adds files, dictation and a model picker. Reduced motion stills the icons. Set a height within the screen, such as min(700px, 100dvh - 2rem), or the composer can sit below the fold.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add ai-chat-interface

Usage

Import AiChatInterface from @/components/wensity/ai-chat-interface and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
"use client";
import { AiChat, type AiChatResponder } from "@/components/wensity/ai-chat-interface";
// Stream from your own API route. Any model works: yield chunks as they arrive.
const respond: AiChatResponder = async function* ({ messages, signal, webSearch, model }) {
const res = await fetch("/api/chat", {
method: "POST",
body: JSON.stringify({ messages, webSearch, model }),
signal,
});
const reader = res.body!.pipeThrough(new TextDecoderStream()).getReader();
while (true) {
const { value, done } = await reader.read();
if (done) break;
yield { type: "text", text: value };
}
};
export default function Chat() {
return <AiChat respond={respond} userName="Ada" height="min(700px, 100dvh - 2rem)" />;
}

Props

PropTypeDefaultDescription
respond({ messages, signal, webSearch, model, files }) => AsyncIterable<AiChatChunk>demoResponderStreams a reply. Yield reasoning, search, source and text chunks, cite sources in text as [n], and stop when signal aborts.
modelsAiChatModel[]Claude, ChatGPT, DeepSeek, Kimi, MistralModels offered in the selector, each with an id, a name and an icon.
defaultModelstring"claude"Model selected at start.
onModelChange(id: string) => void-Fired when a model is picked.
defaultWebSearchbooleantrueWhether replies search the web. On by default, with no toggle in the composer.
onGoogleDrive() => void-Called when Google Drive is picked in the attach menu. Without it, the file picker opens.
suggestionsstring[]16 promptsPrompts offered as completions while typing in a new chat, under a Search the web row.
initialMessagesAiChatMessage[][]Conversation to start with. Empty shows the greeting.
greetingstringtime of dayHeading on an empty chat. Defaults to Good morning, Good afternoon or Good evening from the visitor's clock.
userNamestring-Name added to the default greeting, as in Good morning, Parth.
placeholderstring"Ask anything, or describe a task"Composer placeholder.
acceptstring"image/*,application/pdf,text/*"File types the attach menu accepts.
heightnumber | string700Height of the whole chat, in pixels or any CSS size. Keep it within the screen, for example "min(700px, 100dvh - 2rem)".
onFeedback(reply, value: "up" | "down" | null) => void-Fired when a reply is rated or the rating is cleared.
  • AI Prompt Input component preview

    AI Prompt Input

    An expanding prompt area with a glowing drop zone that breathes open to meet you as you type a thought or drag a file.

  • Animated Loading Skeleton component preview

    Animated Loading Skeleton

    An organic loading state instead of a spinner, with a slow aurora that breathes in the space where your content will land.

  • Voice Reactive Orb component preview

    Voice Reactive Orb

    A breathing voice orb that swells with speech and settles between turns, never jittery and always organic to look at.

  • AI Model Selector component preview

    AI Model Selector

    An AI model selector dropdown that scales out from its trigger and glides the selection pill to whichever model you pick.

Featured in React AI chat UI components.