Alwurts

Chat Input

AI chats 303

About

AI Chat Input

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Chat Input to your project and fits it to your theme.

Code

How Chat Input is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import {
	ChatInput,
	ChatInputSubmit,
	ChatInputTextArea,
} from "@/components/ui/chat-input";
import { useState } from "react";
import { toast } from "sonner";

function ChatInputDemo() {
	const [value, setValue] = useState("");
	const [isLoading, setIsLoading] = useState(false);

	const handleSubmit = () => {
		setIsLoading(true);
		setTimeout(() => {
			toast(value);
			setIsLoading(false);
		}, 1000);
	};

	return (
		<div className="w-full max-w-[400px] h-full">
			<ChatInput
				variant="default"
				value={value}
				onChange={(e) => setValue(e.target.value)}
				onSubmit={handleSubmit}
				loading={isLoading}
				onStop={() => setIsLoading(false)}
			>
				<ChatInputTextArea placeholder="Type a message..." />
				<ChatInputSubmit />
			</ChatInput>
		</div>
	);
}

export { ChatInputDemo }

Dependencies

More by Alwurts

View all
  • Tool Invocation

    Tool Invocation

    46
  • Model Selector

    Model Selector

    41
  • Chat Suggestions

    Chat Suggestions

    13
  • Status Edge

    Status Edge

    7
  • Tool Call

    Tool Call

    4
  • Editable Handle

    Editable Handle

    1
  • JSX Renderer

    JSX Renderer

More in AI chats

View all
  • AI Actions

    AI Actions

    319
  • Agent Chat

    Agent Chat

    17
  • System Message

    System Message

    54
  • Message Thread

    Message Thread

    35
  • Color Picker

    Color Picker

    81
  • AI Task List

    AI Task List

    160
  • Modal Card

    Modal Card

    101
  • Quota Banner

    Quota Banner

    21