AI Chat with Voice Input
blocks/ai-01FreeBlock
A ai chat with voice input block.
Install it
npx shadcn@latest add https://blocks.so/r/ai-01.jsonSource
1'use client';23import {4 IconMicrophone,5 IconPaperclip,6 IconPlus,7 IconSearch,8 IconSend,9 IconSparkles,10 IconWaveSine,11} from '@tabler/icons-react';12import type React from 'react';13import { useRef, useState } from 'react';14import { Button } from '@/components/ui/button';15import {16 DropdownMenu,17 DropdownMenuContent,18 DropdownMenuGroup,19 DropdownMenuItem,20 DropdownMenuTrigger,21} from '@/components/ui/dropdown-menu';22import { Textarea } from '@/components/ui/textarea';23import { cn } from '@/lib/utils';2425export default function Ai01() {26 const [message, setMessage] = useState('');27 const [isExpanded, setIsExpanded] = useState(false);28 const textareaRef = useRef<HTMLTextAreaElement>(null);29 const fileInputRef = useRef<HTMLInputElement>(null);3031 const handleSubmit = (e: React.FormEvent) => {32 e.preventDefault();3334 if (message.trim()) {35 setMessage('');36 setIsExpanded(false);3738 if (textareaRef.current) {39 textareaRef.current.style.height = 'auto';40 }41 }42 };4344 const handleTextareaChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {45 setMessage(e.target.value);4647 if (textareaRef.current) {48 textareaRef.current.style.height = 'auto';49 textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;50 }5152 setIsExpanded(e.target.value.length > 100 || e.target.value.includes('\n'));53 };5455 const handleKeyDown = (e: React.KeyboardEvent) => {56 if (e.key === 'Enter' && !e.shiftKey) {57 e.preventDefault();58 handleSubmit(e as any);59 }60 };6162 return (63 <div className="w-full">64 <h1 className="mx-auto mb-8 max-w-2xl whitespace-pre-wrap text-balance text-pretty px-1 text-center font-semibold text-2xl text-foreground leading-9">65 How can I help you today?66 </h1>6768 <form className="group/composer w-full" onSubmit={handleSubmit}>69 <input70 className="sr-only"71 multiple72 onChange={(e) => {}}73 ref={fileInputRef}74 type="file"75 />7677 <div78 className={cn(79 'mx-auto w-full max-w-2xl cursor-text overflow-clip border border-border bg-transparent bg-clip-padding p-2.5 shadow-lg transition-[border-radius] duration-200 ease-out dark:bg-muted/50',80 isExpanded81 ? "grid rounded-3xl [grid-template-areas:'header'_'primary'_'footer'] [grid-template-columns:1fr] [grid-template-rows:auto_1fr_auto]"82// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from blocks
All 76 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AI Chat with Model Selectionai-02 | blocks | Blocks | Free | 1 dep | |
| AI Chat Compact Interfaceai-03 | blocks | Blocks | Free | 1 dep | |
| AI Chat with File Attachmentsai-04 | blocks | Blocks | Free | 1 dep | |
| AI Elements Chatai-05 | blocks | Blocks | Free | 2 deps | |
| Command Menu with Groupscommand-menu-01 | blocks | Blocks | Free | 1 dep | |
| Command Menu with Keyboard Shortcutscommand-menu-02 | blocks | Blocks | Free | 1 dep | |
| Command Menu with Documentation Searchcommand-menu-03 | blocks | Blocks | Free | 1 dep | |
| Dialog Confirmationdialog-01 | blocks | Blocks | Free | 1 dep |
