Skip to content

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.

🔥 Inspiration 1
🔥 Inspiration 2
🔥 Inspiration 3
🔥 Inspiration 4
🔥 Inspiration 5
🔥 Inspiration 6
🔥 Inspiration 7
🔥 Inspiration 8
🔥 Inspiration 9
🔥 Inspiration 10
Basic Infinite Scroll

Vertical Display

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

Announcement #1: System maintenance tonight
Announcement #2: System maintenance tonight
Announcement #3: System maintenance tonight
Announcement #4: System maintenance tonight
Announcement #5: System maintenance tonight
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.

User 1
User 2
User 3
User 4
User 5
User 6
User 7
User 8
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.

Total Cycles: 0
Interaction Item 1
Interaction Item 2
Interaction Item 3
Interaction Item 4
Interaction Item 5
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.

Short Item 1
Short Item 2
Short Item 3
This is a very long long long long long content item 1
This is a very long long long long long content item 2
This is a very long long long long long content item 3
This is a very long long long long long content item 4
This is a very long long long long long content item 5
This is a very long long long long long content item 6
This is a very long long long long long content item 7
This is a very long long long long long content item 8
This is a very long long long long long content item 9
This is a very long long long long long content item 10
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.

Announcement: Message #1, paused for 2s for reading
Announcement: Message #2, paused for 2s for reading
Announcement: Message #3, paused for 2s for reading
Announcement: Message #4, paused for 2s for reading
Announcement: Message #5, paused for 2s for reading
Announcement: Message #6, paused for 2s for reading
Loop Pause Example

Professional Case: Stock Ticker

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

AAPL189.43▲ +1.2%
TSLA238.45▼ -2.4%
NVDA495.22▲ +5.1%
MSFT374.07▲ +0.8%
AMZN145.20▲ +1.5%
GOOGL132.40▼ -0.3%
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 3 SSR Compatibility Demo
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)

Released under the MIT License.