Components
← All components

Sticky State Observer

stimeo--sticky-observer

Detects whether a position: sticky element is stuck and exposes it as data-stuck.

The stimeo--sticky-observer controller is a pure state-detection utility with no APG widget. Using an IntersectionObserver and a sentinel placed just before the sticky element, it detects when the sentinel scrolls out past the top of the viewport (or a rootSelector container) and sets data-stuck="true" on the sticky element (false otherwise), dispatching stimeo--sticky-observer:change on each transition. data-stuck is a visual hook only — it carries no ARIA role or state. offset feeds a negative top rootMargin and must match the sticky element's CSS top. Behavior only — position: sticky, shadows, and shrink effects are owned by this Playground; the observer is disconnected on disconnect (Turbo included).

running
Sticky heading

Scrollable content paragraph 1. Scroll inside the box to make the heading stick.

Scrollable content paragraph 2. Scroll inside the box to make the heading stick.

Scrollable content paragraph 3. Scroll inside the box to make the heading stick.

Scrollable content paragraph 4. Scroll inside the box to make the heading stick.

Scrollable content paragraph 5. Scroll inside the box to make the heading stick.

Scrollable content paragraph 6. Scroll inside the box to make the heading stick.

Scrollable content paragraph 7. Scroll inside the box to make the heading stick.

Scrollable content paragraph 8. Scroll inside the box to make the heading stick.