#17 · Primary category: AI UI Components & Blocks Library

use-stick-to-bottom

ai chatbot chatgpt claude messages smooth-scrolling

A lightweight React Hook intended mainly for AI chat applications, for smoothly sticking to bottom of messages

Project last updated:06/04/26

GitHub Stars

772

Forks

58

Contributors

12

License

MIT

Why we included this project

Chat apps that stream tokens from an LLM have a deceptively annoying problem: the message list needs to stay pinned to the bottom as new content arrives, and the viewport shouldn't jump around while it happens. This hook handles that without relying on overflow-anchor, which Safari still doesn't support, and it uses ResizeObserver plus a velocity-based spring animation instead of fixed-duration easing, so it copes when streamed messages change size mid-flight. Scrolling up cancels the stickiness whenever the user wants, and the library can tell a real scroll apart from its own animation events, which keeps the behavior sane on mobile. You can attach it to an existing component through refs, or use the bundled component that exposes context for checking isAtBottom and triggering scrolls. It has zero dependencies, so it won't bloat a React app.

Articles for this project

No articles for this project yet.

To suggest a topic or contribute an article, contact us.

Related projects in this category