Thread
nexus-ui/threadFreeComponent
Scrollable chat thread with stick-to-bottom scrolling and jump-to-bottom control
Live preview
live · rendered by the registry
Rendered by nexus-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://nexus-ui.dev/r/thread.jsonSource
1"use client";23import * as React from "react";4import { Slot } from "@radix-ui/react-slot";5import { ArrowDown02Icon } from "@hugeicons/core-free-icons";6import { HugeiconsIcon } from "@hugeicons/react";7import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom";89import { cn } from "@/lib/utils";1011type ThreadProps = React.ComponentProps<typeof StickToBottom>;1213function Thread({14 className,15 resize = "smooth",16 initial = "smooth",17 ...props18}: ThreadProps) {19 return (20 <StickToBottom21 data-slot="thread"22 className={cn("relative w-full h-full", className)}23 resize={resize}24 initial={initial}25 {...props}26 />27 );28}2930type ThreadContentProps = React.ComponentProps<typeof StickToBottom.Content>;3132function ThreadContent({ className, ...props }: ThreadContentProps) {33 return (34 <StickToBottom.Content35 data-slot="thread-content"36 className={cn(37 "flex w-full flex-col gap-6 p-6",38 className,39 )}40 {...props}41 />42 );43}4445type ThreadScrollToBottomProps = React.ComponentProps<"button"> & {46 asChild?: boolean;47};4849function ThreadScrollToBottom({50 asChild = false,51 className,52 children,53 onClick,54 ...props55}: ThreadScrollToBottomProps) {56 const { isAtBottom, scrollToBottom } = useStickToBottomContext();5758 if (isAtBottom) {59 return null;60 }6162 const Comp = asChild ? Slot : "button";6364 return (65 <Comp66 data-slot="thread-scroll-to-bottom"67 type={asChild ? undefined : "button"}68 className={cn(69 !asChild &&70 "absolute bottom-6 left-[50%] flex size-8 translate-x-[-50%] cursor-pointer items-center justify-center rounded-full border border-border bg-secondary text-muted-foreground shadow-sm transition-all hover:bg-border active:scale-95",71 className,72 )}73 onClick={(event) => {74 scrollToBottom();75 onClick?.(event);76 }}77 {...props}78 >79 {children ?? (80 <HugeiconsIcon81 icon={ArrowDown02Icon}82 strokeWidth={2.0}83 className="size-4.5"84 />85 )}86 </Comp>87 );88}8990export { Thread, ThreadContent, ThreadScrollToBottom };
What it pulls in
npm packages
Files it writes
More from nexus-ui
All 15 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Attachmentsattachments | nexus-ui | Components | Free | 4 deps · 2 files | |
| Chain of Thoughtchain-of-thought | nexus-ui | Components | Free | 2 deps · 2 files | |
| Citationcitation | nexus-ui | Components | Free | 4 deps | |
| Feedback Barfeedback-bar | nexus-ui | Components | Free | 1 dep | |
| Imageimage | nexus-ui | Components | Free | 2 deps | |
| Messagemessage | nexus-ui | Components | Free | 9 deps · 2 files | |
| Model Selectormodel-selector | nexus-ui | Components | Free | 3 deps | |
| Prompt Inputprompt-input | nexus-ui | Components | Free | 1 dep |
