Navbar Auto Hide
poyraz/navbar-auto-hideFreeHook
Poyraz Soft Glass Navbar Auto Hide with container-responsive layout and semantic tokens.
Install it
npx shadcn@latest add https://ui.poyrazavsever.com/r/navbar-auto-hide.jsonSource
1"use client";23import * as React from "react";45export interface UseNavbarAutoHideOptions {6 enabled?: boolean;7 threshold?: number;8}910function useNavbarAutoHide({ enabled = true, threshold = 80 }: UseNavbarAutoHideOptions = {}) {11 const [hidden, setHidden] = React.useState(false);12 const lastScrollY = React.useRef(0);1314 React.useEffect(() => {15 if (!enabled) {16 setHidden(false);17 return;18 }1920 function handleScroll() {21 const currentY = window.scrollY;22 setHidden(currentY > lastScrollY.current && currentY > threshold);23 lastScrollY.current = currentY;24 }2526 window.addEventListener("scroll", handleScroll, { passive: true });27 return () => window.removeEventListener("scroll", handleScroll);28 }, [enabled, threshold]);2930 return hidden;31}3233export { useNavbarAutoHide };
What it pulls in
Other registry items
Files it writes
More from poyraz
All 71 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Persistent Announcementpersistent-announcement | poyraz | Hooks | Free | no deps |
