All blocks
[42] AI
AI Chat
A model picker, a question, an answer with steps, code and actions, and a prompt box pinned to the bottom.
1280px
Copy the code
One file with one component and its sample data. It needs @vaneui/ui and its stylesheet, set up as in the installation guide. It passes an onSubmit handler, so in the Next.js App Router add "use client" at the top of its file.
ai-chat.tsx
import { useState, type ReactNode } from "react";import { Avatar, Card, Chip, Code, Col, Container, IconButton, Kbd, List, ListItem, Row, Section, Select, Text, Textarea } from "@vaneui/ui";
function Svg({ children }: { children: ReactNode }) { return ( <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"> {children} </svg> );}
const Sparkle = () => <Svg><path d="M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2.5 2.5M15.5 15.5 18 18M6 18l2.5-2.5M15.5 8.5 18 6" /></Svg>;const Plus = () => <Svg><path d="M12 5v14M5 12h14" /></Svg>;const Copy = () => <Svg><rect x="9" y="9" width="11" height="11" rx="2" /><path d="M5 15V5a2 2 0 0 1 2-2h8" /></Svg>;const ThumbUp = () => <Svg><path d="M7 11v9H4v-9zM7 11l4-8a2 2 0 0 1 3 2l-1 4h6a2 2 0 0 1 2 2l-2 7a2 2 0 0 1-2 2H7" /></Svg>;const Refresh = () => <Svg><path d="M20 11a8 8 0 1 0-2 6M20 4v7h-7" /></Svg>;const Paperclip = () => <Svg><path d="m21 12-8.5 8.5a5 5 0 0 1-7-7L14 5a3.5 3.5 0 0 1 5 5l-8.5 8.5a2 2 0 0 1-3-3L15 8" /></Svg>;const Globe = () => <Svg><circle cx="12" cy="12" r="9" /><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18" /></Svg>;const ArrowUp = () => <Svg><path d="M12 19V5M6 11l6-6 6 6" /></Svg>;
export function AiChat() { const [searchWeb, setSearchWeb] = useState(false);
return ( <Col noGap className="min-h-dvh"> <Row tag="header" justifyBetween borderB padding> <Select aria-label="Model" defaultValue="pro" wFit> <option value="pro">Acme 2 Pro</option> <option value="fast">Acme 2 Fast</option> </Select> <IconButton ghost secondary aria-label="New chat"><Plus /></IconButton> </Row> <Section tag="main" flex1> <Container> <Col lg wFull className="max-w-3xl"> <Row justifyEnd> <Card sm secondary className="max-w-lg"> <Text>How do I export last month's orders as CSV, only the paid ones?</Text> </Card> </Row> <Row itemsStart> <Avatar sm filled alt=""><Sparkle /></Avatar> <Col sm flex1 className="min-w-0"> <Text>Open <Text tag="span" fontSemibold>Orders</Text>, then:</Text> <List listDecimal> <ListItem>Set the status filter to <Code>Paid</Code>.</ListItem> <ListItem>Pick <Code>Last 30 days</Code> in the date filter.</ListItem> <ListItem>Choose <Text tag="span" fontSemibold>Export CSV</Text>. The file has one row per order.</ListItem> </List> <Text>From the API, the same export is one call:</Text> <Card sm secondary noShadow overflowXAuto> <Code transparent>GET /v1/orders?status=paid&since=30d&format=csv</Code> </Card> <Row xs> <IconButton ghost secondary aria-label="Copy the answer"><Copy /></IconButton> <IconButton ghost secondary aria-label="Good answer"><ThumbUp /></IconButton> <IconButton ghost secondary aria-label="Try again"><Refresh /></IconButton> </Row> </Col> </Row> </Col> </Container> </Section> <Section sm sticky primary className="bottom-0"> <Container> <Card tag="form" onSubmit={(e) => e.preventDefault()} wFull shadow className="max-w-3xl"> <Textarea autosize rows={1} noBorder noInsetRing transparent aria-label="Message" placeholder="Ask about your orders, customers or docs" /> <Row justifyBetween> <Row sm> <IconButton type="button" ghost secondary aria-label="Attach a file"><Paperclip /></IconButton> <Chip tag="button" type="button" sm cursorPointer filled={searchWeb} aria-pressed={searchWeb} onClick={() => setSearchWeb((on) => !on)}><Globe /> Search the web</Chip> </Row> <Row sm> <Text xs tertiary mobileHide><Kbd xs>Enter</Kbd> to send</Text> <IconButton type="submit" filled aria-label="Send"><ArrowUp /></IconButton> </Row> </Row> </Card> </Container> </Section> </Col> );}Components in this block
Adapt it with your coding agent
Add the VaneUI MCP server, and your agent reads the component docs and prop tables while it changes the block: the copy, the sample data or the layout.
$ claude mcp add vaneui -- npx -y @vaneui/mcp
Setup for other editors is in the AI assistants guide.