Components
← All components

Stick-to-Bottom

stimeo--stick-to-bottom

Auto-follows appended content to the bottom of a scroll container — unless the user has scrolled up.

The stimeo--stick-to-bottom controller keeps a scroll container (a chat log, a live console) pinned to its newest content — but only while the user is already near the bottom. The container is pinned while its distance from the bottom is within threshold. A MutationObserver on content (or the element) reacts to appended children: while pinned it scrolls to the bottom, while unpinned it holds position, sets data-has-new, and emits new. Scrolling recomputes pinned and reflects data-pinned, emitting pin on change; the scrollToBottom action jumps back down (a "new messages" button). Behavior only — it does not add content (Turbo Stream / the consumer does) and is the minimal follow primitive, not a chat UI (no virtualization or input — that is the premium Chat Base). It is the lightweight member of the scroll family. State is derived from the scroll position each pass (no module-scope state), so connect re-syncs after a Turbo Stream insert; behavior falls back to auto under reduced motion; the auto-scroll never moves focus; and the observer and passive scroll listener are released on disconnect (Turbo navigation included).

running
  • Message 1
  • Message 2
  • Message 3
  • Message 4
  • Message 5
  • Message 6
  • Message 7
  • Message 8