Marquee
spell-ui/marqueeFreeComponent
Infinite scrolling marquee component with customizable speed and direction.
Live preview
live · rendered by the registry
Rendered by spell-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://spell.sh/r/marquee.jsonSource
1"use client";23import React from "react";4import { cn } from "@/lib/utils";56interface MarqueeProps extends React.HTMLAttributes<HTMLDivElement> {7 duration?: number;8 pauseOnHover?: boolean;9 direction?: "left" | "right" | "up" | "down";10 fade?: boolean;11 fadeAmount?: number;12}1314export function Marquee({15 children,16 className,17 duration = 20,18 pauseOnHover = false,19 direction = "left",20 fade = true,21 fadeAmount = 10,22 ...props23}: MarqueeProps) {24 const containerRef = React.useRef<HTMLDivElement>(null);25 const [isPaused, setIsPaused] = React.useState(false);2627 const items = React.Children.toArray(children);28 const isVertical = direction === "up" || direction === "down";2930 return (31 <>32 <style jsx>33 {`34 @keyframes scroll {35 from {36 transform: translateX(0);37 }38 to {39 transform: translateX(-50%);40 }41 }4243 @keyframes scroll-reverse {44 from {45 transform: translateX(-50%);46 }47 to {48 transform: translateX(0);49 }50 }5152 @keyframes scroll-y {53 from {54 transform: translateY(0);55 }56 to {57 transform: translateY(-50%);58 }59 }6061 @keyframes scroll-y-reverse {62 from {63 transform: translateY(-50%);64 }65 to {66 transform: translateY(0);67 }68 }6970 .marquee-scroller {71 display: flex;72 animation: ${73 isVertical74 ? (direction === "up" ? "scroll-y" : "scroll-y-reverse")75 : (direction === "left" ? "scroll" : "scroll-reverse")76 } ${duration}s linear infinite;77 }7879 .marquee-scroller.paused {80 animation-play-state: paused;81 }82 `}83 </style>84 <div85 ref={containerRef}86 className={cn(87 "flex w-full overflow-hidden",88 isVertical && "flex-col",89 className,90 )}91 style={{92 ...(fade && {93 maskImage: isVertical94 ? `linear-gradient(to bottom, transparent 0%, black ${fadeAmount}%, black ${95 100 - fadeAmount96 }%, transparent 100%)`97 : `linear-gradient(to right, transparent 0%, black ${fadeAmount}%, black ${98 100 - fadeAmount99 }%, transparent 100%)`,100 WebkitMaskImage: isVertical101// … truncated
What it pulls in
npm packages
Files it writes
More from spell-ui
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Checkboxanimated-checkbox | spell-ui | Components | Free | 1 dep | |
| Animated Gradientanimated-gradient | spell-ui | Components | Free | no deps | |
| Badgebadge | spell-ui | Components | Free | 2 deps | |
| Bars Spinnerbars-spinner | spell-ui | Components | Free | no deps | |
| Blur Revealblur-reveal | spell-ui | Components | Free | 1 dep | |
| Chartchart | spell-ui | Components | Free | no deps | |
| Color Selectorcolor-selector | spell-ui | Components | Free | no deps | |
| Copy Buttoncopy-button | spell-ui | Components | Free | 1 dep |
