Marquee
wise-ui/marqueeFreeComponent
An infinite scrolling marquee with configurable speed and direction.
Live preview
live · rendered by the registry
Rendered by wise-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://wise-ui.com/r/marquee.jsonSource
1"use client"23import * as React from "react"4import { cn } from "@/registry/wise-ui/lib/utils"56interface MarqueeProps {7 speed?: number8 direction?: "left" | "right"9 pauseOnHover?: boolean10 children: React.ReactNode11 className?: string12}1314function Marquee({15 speed = 40,16 direction = "left",17 pauseOnHover = false,18 children,19 className,20}: MarqueeProps) {21 const containerRef = React.useRef<HTMLDivElement>(null)22 const [contentWidth, setContentWidth] = React.useState(0)23 const scopedId = React.useId().replace(/:/g, "")24 const [paused, setPaused] = React.useState(false)2526 React.useEffect(() => {27 const el = containerRef.current28 if (!el) return29 const measure = () => {30 const first = el.firstElementChild as HTMLElement | null31 if (first) setContentWidth(first.scrollWidth)32 }33 measure()34 const ro = new ResizeObserver(measure)35 ro.observe(el)36 return () => ro.disconnect()37 }, [children])3839 const duration = contentWidth > 0 ? contentWidth / speed : 040 const keyframeName = `marquee-${scopedId}`4142 const from = direction === "left" ? "0%" : "-50%"43 const to = direction === "left" ? "-50%" : "0%"4445 return (46 <div className={cn("overflow-hidden", className)}>47 <style>{`48 @keyframes ${keyframeName} {49 from { transform: translateX(${from}); }50 to { transform: translateX(${to}); }51 }52 `}</style>53 <div54 ref={containerRef}55 className="flex w-max"56 style={{57 animationName: keyframeName,58 animationDuration: `${duration}s`,59 animationTimingFunction: "linear",60 animationIterationCount: "infinite",61 animationPlayState: paused ? "paused" : "running",62 }}63 onMouseEnter={() => pauseOnHover && setPaused(true)}64 onMouseLeave={() => pauseOnHover && setPaused(false)}65 >66 <div className="flex shrink-0">{children}</div>67 <div className="flex shrink-0" aria-hidden>68 {children}69 </div>70 </div>71 </div>72 )73}74Marquee.displayName = "Marquee"7576export { Marquee }77export type { MarqueeProps }
What it pulls in
npm packages
Files it writes
More from wise-ui
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Tabsanimated-tabs | wise-ui | Components | Free | 3 deps | |
| Border Beamborder-beam | wise-ui | Components | Free | 3 deps | |
| Data Tabledata-table | wise-ui | Components | Free | 3 deps | |
| Dockdock | wise-ui | Components | Free | 3 deps | |
| Dot Matrixdot-matrix | wise-ui | Components | Free | 2 deps | |
| Editable Texteditable-text | wise-ui | Components | Free | 4 deps | |
| Gradient Sidebargradient-sidebar | wise-ui | Components | Free | 3 deps | |
| Kanban Boardkanban-board | wise-ui | Components | Free | 6 deps |
