Floating Header
azemmur/layouts-floating-headerFreeComponent
A scroll-driven floating header that morphs width, radius, and elevation as the user scrolls.
Install it
npx shadcn@latest add https://azemmur.raouf.codes/r/layouts-floating-header.jsonSource
1// Copyright (c) 2026 raouf.codes - Azemmur23'use client';45import { cn } from '@/lib/utils';6import { cva, type VariantProps } from 'class-variance-authority';7import {8 motion,9 useScroll,10 useTransform,11 useSpring,12 useMotionTemplate,13 type HTMLMotionProps,14} from 'motion/react';15import * as React from 'react';1617const floatingHeaderVariants = cva('sticky z-50 flex items-center mx-auto', {18 variants: {19 intent: {20 primary: 'text-primary-foreground bg-primary border-primary',21 accent: 'text-accent-foreground bg-accent border-accent',22 secondary: 'text-secondary-foreground bg-secondary border-secondary',23 success: 'text-success-foreground bg-success border-success',24 warning: 'text-warning-foreground bg-warning border-warning',25 error: 'text-error-foreground bg-error border-error',26 info: 'text-info-foreground bg-info border-info',27 neutral: 'text-foreground bg-background border-border',28 },29 styling: {30 solid: 'border-none',31 outline: 'border border-2 bg-background',32 glass: 'backdrop-blur-md border-none',33 },34 size: {35 sm: 'px-4 py-2 text-sm gap-2',36 md: 'px-6 py-3 text-sm gap-3',37 lg: 'px-8 py-4 text-base gap-4',38 },39 },40 compoundVariants: [41 { intent: 'primary', styling: 'outline', className: 'text-primary' },42 { intent: 'accent', styling: 'outline', className: 'text-accent' },43 { intent: 'secondary', styling: 'outline', className: 'text-secondary' },44 { intent: 'success', styling: 'outline', className: 'text-success' },45 { intent: 'warning', styling: 'outline', className: 'text-warning' },46 { intent: 'error', styling: 'outline', className: 'text-error' },47 { intent: 'info', styling: 'outline', className: 'text-info' },48 { intent: 'neutral', styling: 'outline', className: 'text-foreground' },49 { styling: 'glass', intent: 'primary', className: 'bg-primary/60' },50 { styling: 'glass', intent: 'accent', className: 'bg-accent/60' },51 { styling: 'glass', intent: 'secondary', className: 'bg-secondary/60' },52 { styling: 'glass', intent: 'success', className: 'bg-success/60' },53 { styling: 'glass', intent: 'warning', className: 'bg-warning/60' },54 { styling: 'glass', intent: 'error', className: 'bg-error/60' },55 { styling: 'glass', intent: 'info', className: 'bg-info/60' },56 { styling: 'glass', intent: 'neutral', className: 'bg-background/60' },57 ],58 defaultVariants: {59 intent: 'neutral',60 styling: 'glass',61// … truncated
What it pulls in
npm packages
Files it writes
More from Azemmur
All 27 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Blur Imagecomponents-blur-image | Azemmur | Components | Free | 1 dep | |
| Buttoncomponents-button | Azemmur | Components | Free | 1 dep | |
| Floating Dockcomponents-floating-dock | Azemmur | Components | Free | 2 deps · 6 files | |
| Speed Dialcomponents-speed-dial | Azemmur | Components | Free | 2 deps · 7 files | |
| Tabscomponents-tabs | Azemmur | Components | Free | 2 deps · 9 files | |
| Theme Switchcomponents-theme-switch | Azemmur | Components | Free | 4 deps | |
| Timelinecomponents-timeline | Azemmur | Components | Free | 2 deps · 8 files | |
| Blur Image Demodemo-components-blur-image | Azemmur | Components | Free | no deps |
