Header 1
uifoundry/header-1FreeBlock
Header 1 Block with adaptive scroll-based styling
Live preview
live · rendered by the registry
Rendered by uifoundry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uifoundry.dev/r/header-1.jsonSource
1"use client";23import { Menu, X } from "lucide-react";4import Link from "next/link";5import { useEffect, useState, type ComponentPropsWithRef } from "react";6import type { Header_1_Block, MediaField as MediaFieldProps } from "~/payload-types";7import { cn } from "@/registry/default/utils";8import { Button } from "@/registry/ui/button";9import MediaField from "@/registry/default/lib/fields/media";1011export * from "./config";1213export default function Header_1({14 preview = false,15 brandLogo,16 logoHref = "/",17 menuItems,18 actionButtons,19 ...navProps20}: { preview?: boolean } & Header_1_Block & ComponentPropsWithRef<"nav">) {21 const [menuState, setMenuState] = useState(false);22 const [isScrolled, setIsScrolled] = useState(false);2324 useEffect(() => {25 const handleScroll = () => {26 setIsScrolled(window.scrollY > 50);27 };28 window.addEventListener("scroll", handleScroll);29 return () => {30 window.removeEventListener("scroll", handleScroll);31 };32 });3334 return (35 <header>36 <nav37 data-state={menuState && "active"}38 id="header"39 className={cn("fixed z-20 w-full px-2", preview && "relative")}40 {...navProps}41 >42 <div43 className={cn(44 "mx-auto mt-2 max-w-6xl px-6 transition-all duration-300 lg:px-12",45 isScrolled &&46 "bg-background/50 max-w-4xl rounded-2xl border backdrop-blur-lg lg:px-5",47 )}48 >49 <div className="relative flex flex-wrap items-center justify-between gap-6 py-3 lg:gap-0 lg:py-4">50 <div className="flex w-full justify-between lg:w-auto">51 {brandLogo && (52 <Link53 href={logoHref}54 aria-label="home"55 className="relative h-8 w-24 lg:w-32"56 >57 <MediaField58 media={brandLogo as MediaFieldProps}59 fill60 className="object-contain object-left"61 />62 </Link>63 )}6465 <button66 onClick={() => setMenuState(!menuState)}67 aria-label={menuState == true ? "Close Menu" : "Open Menu"}68 className="relative z-20 -m-2.5 -mr-4 block cursor-pointer p-2.5 lg:hidden"69 >70 <Menu className="m-auto size-6 duration-200 in-data-[state=active]:scale-0 in-data-[state=active]:rotate-180 in-data-[state=active]:opacity-0" />71 <X className="absolute inset-0 m-auto size-6 scale-0 -rotate-180 opacity-0 duration-200 in-data-[state=active]:scale-100 in-data-[state=active]:rotate-0 in-data-[state=active]:opacity-100" />72 </button>7374// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from uifoundry
All 54 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Color Fieldcolor-field | uifoundry | Blocks | Free | 4 deps · 2 files | |
| Coming Soon 1coming-soon-1 | uifoundry | Blocks | Free | 3 deps · 2 files | |
| CTA 1cta-1 | uifoundry | Blocks | Free | 3 deps · 2 files | |
| CTA 2cta-2 | uifoundry | Blocks | Free | 3 deps · 2 files | |
| CTA 3cta-3 | uifoundry | Blocks | Free | 3 deps · 2 files | |
| Custom Headercustom-header | uifoundry | Blocks | Free | 4 deps · 3 files | |
| Features 1features-1 | uifoundry | Blocks | Free | 3 deps · 2 files | |
| Features 2features-2 | uifoundry | Blocks | Free | 4 deps · 2 files |
