Chat Message Area
simple-ai/chat-message-areaFreeComponent
A component that adds auto scrolling functionality to a list of messages.
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-message-area.jsonSource
1import { ChevronDown } from "lucide-react";2import { type ComponentProps, useCallback } from "react";3import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom";4import { Button } from "@/components/ui/button";5import { cn } from "@/lib/utils";67interface ChatMessageAreaScrollButtonProps {8 alignment?: "left" | "center" | "right";9 className?: string;10}1112export function ChatMessageAreaScrollButton({13 alignment = "center",14 className,15}: ChatMessageAreaScrollButtonProps) {16 const { isAtBottom, scrollToBottom } = useStickToBottomContext();1718 const handleScrollToBottom = useCallback(() => {19 scrollToBottom();20 }, [scrollToBottom]);2122 if (isAtBottom) {23 return null;24 }2526 const alignmentClasses = {27 left: "left-4",28 center: "left-1/2 -translate-x-1/2",29 right: "right-4",30 };3132 return (33 <Button34 variant="secondary"35 size="icon"36 className={cn(37 "absolute bottom-4 rounded-full shadow-lg hover:bg-secondary",38 alignmentClasses[alignment],39 className,40 )}41 onClick={handleScrollToBottom}42 >43 <ChevronDown className="h-4 w-4" />44 </Button>45 );46}4748type ChatMessageAreaProps = ComponentProps<typeof StickToBottom>;4950export function ChatMessageArea({ className, ...props }: ChatMessageAreaProps) {51 return (52 <StickToBottom53 className={cn("flex-1 relative h-full overflow-y-auto", className)}54 resize="smooth"55 initial="smooth"56 {...props}57 />58 );59}6061type ChatMessageAreaContentProps = ComponentProps<typeof StickToBottom.Content>;6263export function ChatMessageAreaContent({64 className,65 ...props66}: ChatMessageAreaContentProps) {67 return (68 <StickToBottom.Content69 className={cn("max-w-2xl mx-auto w-full h-full py-2", className)}70 {...props}71 />72 );73}
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 Inputchat-input | simple-ai | Components | Free | 7 deps | |
| Chat Messagechat-message | simple-ai | Components | Free | no deps | |
| 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 |
