Back to components
ElementLayoutFree

Sticky Header React component

A site header that stays out of the way: it slides up while you scroll down and comes back the moment you scroll up, turns compact and frosted after the first few pixels, shows reading progress along its edge, and folds its links into a menu on narrow screens.

About the Sticky Header component

Sticky Header is a site header that stays at the top of the page. At the top it is transparent and roomy, and once you scroll it turns compact and solid with a blurred background. In hide mode it slides away while you scroll down and comes back as soon as you scroll up; in shrink mode it always stays. A thin reading-progress bar can run along its bottom edge.

brand sets the logo, links the navigation links and cta the button on the right. Hovering a link slides a pill behind it. threshold sets how far to scroll before it turns compact (24px by default), showProgress shows the progress bar, and contained makes it follow the nearest scrolling parent instead of the window. When the header is narrower than 640px, the links and the button fold into a menu that opens under the bar.

When to use it

Use Sticky Header for marketing sites, docs and blogs where navigation should always be one scroll-up away but shouldn't cover content while people read.

Use behavior="shrink" for apps and dashboards where the header holds controls people need at all times.

Installation

Add the Sticky Header component to your project with the shadcn CLI. It lands in components/sticky-header.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/sticky-header

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

More Layout components

Section Container
Free
Bento Grid
Free
Shape Divider
Free
Masonry Grid
Free
Fieldset
Free
Panel
Free