Sticky

Top or bottom sticky surface for navigation, persistent actions and summary content

View documentation

Sticky header

Scroll inside the box. A sticky element needs a scrolling ancestor — here it is the bordered container rather than the page.

Release checklist

12 items
  1. 1 Freeze the release branch
  2. 2 Run the full test suite
  3. 3 Regenerate the component catalog
  4. 4 Review the changelog entries
  5. 5 Bump the package version
  6. 6 Tag the release commit
  7. 7 Publish the package
  8. 8 Verify the docs build
  9. 9 Announce in the changelog channel
  10. 10 Close the milestone
  11. 11 Open the next milestone
  12. 12 Update the roadmap

Bottom action bar

side="bottom" pins the actions to the lower edge, and as="footer" keeps the document outline honest about what the region is.

Deployment window

A long form is the usual reason to pin the actions: the reader should never have to scroll back to find out how to save. The bar below stays on the bottom edge of this scroll container until the content ends.

Because the primitive is CSS only, the bar keeps working with a Turbo Frame swapping the content above it. There is no controller measuring anything, so nothing has to be re-initialised after a render.

The as prop decides the wrapper tag. Here it is a footer, so the document outline says what the region is instead of leaving another anonymous div.

Keep scrolling to see the bar detach when the content finally runs out underneath it.

Everything below this line exists only to make the container taller than its own height, which is what gives the sticky edge something to hold on to.

One more paragraph, and the scroll finally reaches the end.

Without the surface

:surface="false" contributes position and nothing else, so a child that already owns its visual treatment does not end up on a second surface.

Build 4128
Passing on 3 runners

With surface disabled the primitive contributes nothing but the sticky position: no border, no background, no backdrop blur. The card underneath keeps its own treatment and there is no second surface stacked behind it.

The offset of 1rem is the gap the card keeps from the top edge while it is pinned, so it reads as a floating card rather than a bar welded to the container.

Use the default surface when the sticky region is the chrome itself — a toolbar, a section nav — and turn it off when the child already looks like something.

The rest of this text exists to give the container a scroll long enough to watch the card hold its position.

Sticky positioning only engages inside the nearest scrolling ancestor, which here is this box.

One last paragraph so the scroll runs a little further.

Sticking to the page

With no scroll container of its own, the nearest scrolling ancestor is the window. The bar travels only as far as the section that contains it — scroll the page to watch it attach and let go.

This example has no scroll container of its own. The nearest scrolling ancestor is the window, so the bar above pins itself one rem below the top of the viewport while this section is on screen, and lets go as soon as the section scrolls past.

That boundary is the part people miss: a sticky element never escapes its parent. It travels exactly as far as the block that contains it, which is why a page-level bar belongs high in the markup rather than inside the first section it should outlive.

The offset exists for the same reason a fixed header does: whatever already occupies the top of the viewport has to be cleared, and the value is a plain CSS length rather than a prop the component has to interpret.

Scroll slowly through this block and the bar stays with you. Scroll past the end of it and the bar leaves with the section, because the containing block ran out.

The primitive adds no JavaScript. There is no scrollspy, no hash management, and no measurement, so nothing here needs to be re-initialised after a Turbo Frame render replaces the content.

What is left is the CSS contract: a side, an offset, an optional surface, and a wrapper tag that says what the region is.

Everything from here down exists to make the section tall enough to demonstrate the travel.

Sticky elements also respect the stacking context they are created in — the preset gives this one z-20, below the overlay surfaces that live at z-50.

That ordering is why a sheet or a modal always covers the bar instead of fighting it.

And this is the end of the section, where the bar detaches.