LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Layout

Sticky header

Also called sticky navbar, sticky nav, or fixed header

A top bar that stays pinned to the top of the screen while the page scrolls underneath it, so navigation is always one click away.

import { useState } from 'react';
import { useMotionValueEvent, useScroll } from 'motion/react';

const LINKS = ['Product', 'Pricing', 'Docs'];

// Add `scroll-pt-16` to <html> so anchor links don't land under the header.
export function SiteHeader() {
  const { scrollY } = useScroll();
  const [scrolled, setScrolled] = useState(false);
  useMotionValueEvent(scrollY, 'change', (y) => setScrolled(y > 8));

  return (
    <header
      data-scrolled={scrolled || undefined}
      className='sticky top-0 z-50 flex h-16 items-center justify-between border-b border-transparent bg-background px-6 transition-[background-color,border-color,box-shadow] duration-200 data-scrolled:border-border data-scrolled:bg-background/80 data-scrolled:shadow-sm data-scrolled:backdrop-blur-md'
    >
      <a href='/' className='font-semibold'>
        Tripmate
      </a>
      <nav className='flex gap-6 text-sm text-muted-foreground'>
        {LINKS.map((label) => (
          <a
            key={label}
            href={`#${label.toLowerCase()}`}
            className='hover:text-foreground'
          >
            {label}
          </a>
        ))}
      </nav>
    </header>
  );
}
Make the site header sticky: position: sticky at top: 0, 64px tall, z-index 50. Once the page has scrolled more than 8px, fade in a bottom border and a soft shadow and switch the background to 80% opacity with a 12px backdrop blur over 200ms. Add scroll-padding-top: 64px so anchor links are not hidden under it.

Paste into Layerwise or any AI coding tool.

What is Sticky header?

A sticky header keeps the logo, navigation, and main action in view as people scroll. Many sites add a small change once the page moves: a shadow or border appears, the background turns semi-transparent with a blur, or the bar shrinks a little. That change shows that content is sliding under the header.

In CSS it takes two lines: position: sticky and top: 0. The header stays in the normal page flow until it reaches the top of the screen, then pins there. position: fixed also pins it, but takes it out of the flow, so the page needs extra top padding to keep the header from covering the first lines of content.

Keep it short, about 56 to 64px, since it takes space permanently, especially on phones. If sticky seems to do nothing, check the parents: an ancestor with overflow: hidden or overflow: auto becomes the box it sticks inside. Give the header a z-index so cards and images pass beneath it, and set scroll-padding-top so in-page links do not land under it.

Often confused with

Scroll pinning
Scroll pinning holds a section in place for a stretch of scrolling while an animation plays, then lets it go. A sticky header stays pinned for the whole page.

Related terms

All terms

Scroll pinning

A scroll effect that holds a section in place while its content animates through several states, then releases it to scroll away.

Glassmorphism

A visual style where panels look like frosted glass: translucent, blurred backgrounds with a thin light border over colorful shapes.

Z-index

A CSS property that decides which element appears on top when elements overlap, with higher numbers sitting closer to the viewer.

Overflow

A CSS property that decides what happens when content is bigger than its box: spill out, get clipped, or scroll inside it.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit
position: sticky;top: 0;
acme.com
AcmeSign up

Popular photos

People crossing a bright, sign-covered street in TokyoA dense carpet of red, yellow, and white flowersCurved blue-and-white towers seen from belowA latte with leaf art in a white cupHot air balloons drifting over a rocky valleyGreen northern lights over snowy peaksBold strokes of red, yellow, pink, and teal paintA sand dune ridge under a clear blue skyPink over-ear headphones on a pink backgroundA winding road through yellow and orange trees, seen from aboveMonstera leaves against a white wallNeon signs glowing over a city street at night