Menu
All plugins

Sticky Bars for Bricks

Pin one or more bars under your header and make them behave as a set. Two elements: Sticky Bar turns the section it sits in into a pinned bar, and Scroll Spy Bar is a section nav that highlights where you are and jumps to each section. They work with Advanced Header Scroll: when the header hides on scroll down and returns on scroll up, the bars follow it.

Open the live demo

Sticky Bar

  • Place the element inside a top-level Section. That Section becomes the bar. Sections must sit directly in the page content, not inside another container.
  • Bar name gives the bar a short name such as promo or spy.
  • Gives way to lists the names of other bars. This bar slides away when one of them reaches its place, so a promo bar can hand over to the section nav.
  • Choose a background, a bottom line, a blur behind and whether a shadow appears once it is stuck.
  • Only stick from this width leaves the bar in the normal flow on small screens.

Scroll Spy Bar

  • Finds its sections on the page by class or by attribute. Both work together: add the class spy-section to a section, or the attribute data-spy-section. Or give your own selector in Sections are.
  • The link text comes from data-title, then data-spy-title, then the first heading in the section. A section without an ID is given one.
  • The current section is marked as bold, underline or a pill. Bold does not shift the other links, because room is reserved for it.
  • On small screens the links become a dropdown showing the current section. It closes when you pick one, click outside or press Escape.
  • It is also a Sticky Bar, so every Sticky Bar setting applies to it.

How the stack behaves

  • Bars stack in page order under the header. When the header slides away, they move up to fill the space, and move down again when it returns.
  • The header is found automatically when it uses Advanced Header Scroll. For any other fixed header, give its selector in Header to sit under.
  • Jumping to a section lands it just under the pinned bars, allowing for any bar that will give way.
  • Opening a page with a section address in the link scrolls to that section.

For developers

  • The element sets --sb-top (header height in view) and --sb-bars (total height of stacked bars) on the page, so your own anchors can use scroll-margin-top.
  • A stkb:spy event fires on the nav when the current section changes, with the index and ID.
  • STKB.refresh() picks up bars added after the page loaded.

Good to know

  • Nothing is pinned inside the Bricks builder, so you can edit normally. A small label marks the element.
  • Reduced motion is respected: bars swap without sliding.