shadcn.io is not affiliated with official shadcn/ui
Sticky Nav FAQ Block for Radix UI
A sticky-nav FAQ for a web host: a horizontal topic bar that follows the page while four bands of always-open answers scroll under it.
Installation
Overview
A sticky-nav FAQ for React with Radix UI. Under a compact header, a horizontal bar of four topic links sticks to the top of the screen while four bands scroll under it; each band names its topic at the start and lays its answers out as open questions and answers in a definition list, two across from sm. The topic in view is underlined as you scroll, a link jumps to its band and the band lands clear of the bar, and a contact band closes the block. The bar scrolls sideways when the links don't fit. It's built from Guides and Button, a nav with plain links and a definition list, with a small scroll listener for the underline and your theme's tokens for every colour. For reference pages where every answer should be visible and findable without opening anything.
FAQ
How do I change the topics and answers?
Edit TOPICS at the top of the file: each topic has an id, a label, a one-line blurb and its questions (an id, the question and a short answer). The bar's links, the bands and the underline all come from that list. Keep answers to a sentence: every answer is on the page at once, so a long one lengthens it.
Why doesn't the bar stick in my page?
A sticky element stops working when an ancestor between it and the page's scroll has overflow: hidden, auto or scroll. The block adds none (its section clips only horizontally, with overflow-x: clip, which is fine); if the bar doesn't stick, look for an overflow in your own layout, or in a wrapper that previews the block. It sticks at top-0: add the height of a fixed site header to top- and to the bands' scroll-mt-.
How does the underline know which topic I'm reading?
A scroll listener, added while the block is mounted, takes the last band whose top has passed the bar as the topic in view, and the last band once you reach the end of the page, where it may never get that far. The current link carries aria-current="location", so the underline isn't the only signal. A click on a link marks its topic at once.
How does it work with a keyboard and a screen reader?
The bar is a navigation landmark named "Topics" with plain links: Tab reaches them, Enter jumps to the band, and focus follows the jump. Each band is a section named by its h3, and its questions and answers are terms and descriptions in a definition list, so a screen reader reads each pair together.