Marquee
hex-ui/marqueeFreeComponent
A marquee component that infinitely scrolls content in a horizontal or vertical direction.
Live preview
live · rendered by the registry
Rendered by hex-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://hexui.sh/r/marquee.jsonSource
1import { type ComponentPropsWithoutRef } from "react"23import { cn } from "@/lib/utils"45interface MarqueeProps extends ComponentPropsWithoutRef<"div"> {6 /**7 * Optional CSS class name to apply custom styles8 */9 className?: string10 /**11 * Whether to reverse the animation direction12 * @default false13 */14 reverse?: boolean15 /**16 * Whether to pause the animation on hover17 * @default false18 */19 pauseOnHover?: boolean20 /**21 * Content to be displayed in the marquee22 */23 children: React.ReactNode24 /**25 * Whether to animate vertically instead of horizontally26 * @default false27 */28 vertical?: boolean29 /**30 * Number of times to repeat the content31 * @default 432 */33 repeat?: number34}3536export function Marquee({37 className,38 reverse = false,39 pauseOnHover = false,40 children,41 vertical = false,42 repeat = 4,43 style,44 ...props45}: MarqueeProps) {46 // Edge-fade mask applied via CSS mask-image so content fades out at both ends.47 const fadeMask = vertical48 ? "linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%)"49 : "linear-gradient(to right, transparent 0%, black 12%, black 88%, transparent 100%)"5051 return (52 <div53 {...props}54 style={{55 ...style,56 maskImage: fadeMask,57 WebkitMaskImage: fadeMask,58 }}59 className={cn(60 "group relative flex gap-(--gap) overflow-hidden [--duration:40s] [--gap:12px]",61 vertical ? "flex-col" : "flex-row",62 className63 )}64 >65 {/* Duplicate children N times so the marquee loops seamlessly without a visible gap. */}66 {Array.from({ length: repeat }).map((_, i) => (67 <div68 key={i}69 className={cn(70 "flex shrink-0 justify-around gap-(--gap) motion-reduce:animate-none",71 vertical72 ? "animate-marquee-vertical flex-col"73 : "animate-marquee flex-row",74 reverse && "direction-[reverse]",75 pauseOnHover && "group-hover:paused"76 )}77 >78 {children}79 </div>80 ))}81 </div>82 )83}
