Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Hooks & Utilities

useStickToBottom

Hooks & Utilities

useStickToBottom React hook in TypeScript

useShortcutButton
Live props
Options
enabled
threshold72px
initial
resize
  1. Home
  2. Components
  3. Hooks & Utilities
  4. useStickToBottom
Pro

useStickToBottom React hook in TypeScript

v1.0.0·Added in 1.0.0

A React hook that keeps a chat, a log or streaming output pinned to its bottom while it grows, and lets go when the reader scrolls up.

The demo plays a conversation whose answers stream in word by word, and the panel follows them down. Scroll up with the wheel, a finger or the keys while an answer is still arriving: following stops at once (isFollowing turns off), the text keeps growing below and a New messages button appears. Tap it, or scroll back to the end, and it follows again. Pause stops the script.

useStickToBottom is a Pro React hook in the React hooks and utilities category, written in TypeScript for React 19. It installs as source with npx wingo-ui@latest add use-stick-to-bottom, together with Motion presets.

Add to a project

Requirements: React 19, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add use-stick-to-bottom

useStickToBottom is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans

Usage

Import useStickToBottom from @/hooks/use-stick-to-bottom.

"use client"

import { useStickToBottom } from "@/hooks/use-stick-to-bottom"
import { Button } from "@/components/ui/button"

export function Conversation({ messages }: { messages: { id: string; text: string }[] }) {
  const { scrollRef, contentRef, isAtBottom, scrollToBottom } = useStickToBottom()

  return (
    <div className="relative h-96">
      <div ref={scrollRef} className="h-full overflow-y-auto overscroll-contain">
        <div ref={contentRef} className="flex flex-col gap-3 p-4">
          {messages.map((m) => <p key={m.id}>{m.text}</p>)}
        </div>
      </div>
      {!isAtBottom && (
        <Button size="sm" radius="full" className="absolute bottom-3 left-1/2 -translate-x-1/2" onClick={() => scrollToBottom()}>
          New messages
        </Button>
      )}
    </div>
  )
}

API

  • enableddefault true
    boolean

    useStickToBottom(options?): follow new content while the reader is at the bottom. false never scrolls by itself (scrollToBottom still works).

  • thresholddefault 72
    number

    Distance in px from the bottom that still counts as at the bottom: isAtBottom, and where scrolling back down re-sticks.

  • initialdefault "instant"
    "instant" | "smooth" | false

    How to reach the bottom when the scroller attaches (opening a conversation). false starts at the top and does not follow until the reader scrolls down.

  • resizedefault "smooth"
    "smooth" | "instant"

    How to follow content that grows while stuck: smooth eases toward a bottom that is re-read every frame, so a streaming answer glides; instant jumps. Reduced motion always jumps.

  • returns
    { scrollRef; contentRef; isAtBottom: boolean; isFollowing: boolean; scrollToBottom(behavior?): void; stopFollowing(): void }

    scrollRef goes on the overflow-y-auto element, contentRef on the element inside it that grows (defaults to the first child). isAtBottom and isFollowing re-render only when they flip: show a jump-to-latest button while !isAtBottom. scrollToBottom scrolls down and follows again (call it after sending a message); stopFollowing lets go without scrolling.

Examples

Live log tail

A new line every 700ms. The view follows the newest one; scroll up to read and a Jump to latest button appears.

Dependencies

motion

Files

  • hooks/use-stick-to-bottom.ts

FAQ

Is the useStickToBottom hook free?

The preview, props and docs are free; copying the source needs a Pro plan. See plans.

How do I install useStickToBottom?

Run npx wingo-ui@latest add use-stick-to-bottom. It also adds the Wingo UI item it builds on (Motion presets). With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/use-stick-to-bottom.

See also

useScrollEdgeshookuseScrollStatehookScroll AreaBack To Top

Used in

Log ViewerAgent Status CardChat ThreadReasoning IndicatorTool Call TimelineInbox Page

More React hooks and utilities

AI ChatlibChart kitlibCommercelibDate utilslibFile exportlibFile typeslib
All 36 React hooks and utilities

Articles using this component

  • React Log Viewer: Stream 100,000 Lines With Regex Search

    Component guides · Oct 16, 2026 · 8 min read

  • React Markdown Streaming Without Flicker or Scroll Jumps

    Building UI with AI agents · Oct 16, 2026 · 10 min read

PrevioususeShortcutNext Button
Northwind assistantisAtBottomisFollowing
Hi! Can you help me with my customer accounts?
Sure. I can look up invoices, send reminders and build collection reports. Where should I start?
72px · initial instant · resize smooth · on

Scroll up while an answer streams: it lets go. Scroll back down and it follows again.