Skip to content
Latestv1.0.63

Marquee ​

High-performance, seamless scrolling marquee component. Driven by CSS animations, supports horizontal/vertical scrolling, dynamic content filling, and ultimate interaction experience.

Basic Usage ​

The simplest infinite horizontal scrolling.

Basic Infinite Scroll

Vertical Display ​

Set direction="vertical" for vertical scrolling. Note: A specific height is usually required for the container in vertical mode.

Vertical Scrolling

Edge Gradient ​

Enable the gradient attribute to add a gradient fade on both sides of the scroll container, making edge transitions smoother and more natural. You can customize the color and width.

Edge Gradient Fade

Interaction and State Control ​

Supports pause on hover, event listening, and manual play control. Use the play attribute for precise animation control, and the cycle-complete event to capture the end of each scrolling cycle.

Interaction Control

Constant Speed ​

In scenarios with variable content length, use speed (px/s) instead of duration to ensure different content lengths scroll at exactly the same speed, avoiding visual jitter.

Constant Speed Demo

Viewport Sensing and Loop Delay ​

Use pause-on-hidden to automatically stop animation when the component leaves the viewport to save performance. Use delay and loop-delay attributes for elegant pauses before the first cycle and between each subsequent cycle.

Loop Pause Example

Professional Case: Stock Ticker ​

Combine gradients and custom styles to create a professional data display.

Stock Ticker

Use in Nuxt ​

YH-UI perfectly adapts to Nuxt 3. You can directly use it in app.vue or any page.

Auto-import

If you use the @yh-ui/nuxt module, YhMarquee will be automatically loaded on demand with full styles.

Nuxt Adaptation

API ​

Props ​

PropDescriptionTypeDefault
directionScroll direction'horizontal' | 'vertical''horizontal'
durationDuration for one scrolling cycle (seconds)number20
reverseWhether to scroll in reversebooleanfalse
pause-on-hoverWhether to pause on hoverbooleantrue
pause-on-clickWhether to pause on clickbooleanfalse
gapGap between content itemsnumber | string0
gradientWhether to enable edge gradient fadebooleanfalse
gradient-colorGradient fade colorstring'#ffffff'
gradient-widthWidth of the gradient fadenumber | string'40px'
auto-fillWhether to auto-fill when content is insufficientbooleantrue
playWhether to play animationbooleantrue
loopLoop count (0 for infinite)number0
speedScrolling speed (px/s), will override duration if setnumber0
delayDelay before starting animation (seconds)number0
loop-delayPause duration after each cycle ends (seconds)number0
pause-on-hiddenWhether to auto-pause when component leaves viewportbooleantrue

Events ​

Event NameDescriptionCallback Parameters
cycle-completeTriggered when a cycle completes-

Slots ​

Slot NameDescription
defaultContent to be scrolled

Expose ​

NameDescriptionType
calculateClonesManually trigger clone count calculation (useful after dynamic content resize)() => Promise<void>
containerRefDOM ref to the outer containerHTMLElement | null
contentRefDOM ref to the content containerHTMLElement | null

Theme Variables ​

All color variables are integrated with the global theme system and support dark mode:

VariableDefaultDescription
--yh-marquee-gap0pxGap between content items
--yh-marquee-duration20sAnimation duration
--yh-marquee-iteration-countinfiniteAnimation iteration count
--yh-marquee-directionnormalAnimation playback direction
--yh-marquee-play-staterunningAnimation play state
--yh-marquee-gradient-colorvar(--yh-bg-color)Edge gradient color (follows theme background)
--yh-marquee-gradient-width40pxEdge gradient width
--yh-marquee-clone-count1Internally calculated clone multiplier (readonly)

Type Exports ​

NameDescription
YhMarqueePropsComponent props type
YhMarqueeEmitsComponent emits type
YhMarqueeSlotsComponent slots type
YhMarqueeExposeComponent expose type
YhMarqueeDirectionDirection union type
YhMarqueeInstanceComponent instance type

Released under the MIT License.