Components
Auto-hide Navbar
A navbar that hides as you scroll down and returns as you scroll up.
Scroll this page down and back up to see the bar hide and return.
<AutoHideNavbar>
<MyNav />
</AutoHideNavbar>Installation
npx shadcn@latest add https://ui.zjkm.tech/r/auto-hide-navbar.jsonimport { AutoHideNavbar } from "@/components/auto-hide-navbar"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Wrap your navbar and it slides away as you scroll down, then comes back as soon as you scroll up, giving content the room. It never hides while something inside it has keyboard focus.
import { AutoHideNavbar } from "@/components/auto-hide-navbar";
export function SiteHeader() {
return (
<AutoHideNavbar>
<MyNav />
</AutoHideNavbar>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | Your navbar's content. | |
threshold | number | 64 | Pixels scrolled before it may hide. |
className | string | Classes for the root element. |
With reduced motion, it hides and returns without sliding.