Marquee
Scrolls content continuously across the screen, such as a row of logos.
Usage
import { Marquee } from '@leverui/components';
<Marquee.Root>
<Marquee.Viewport>
<Marquee.Content>
<Marquee.Item />
</Marquee.Content>
</Marquee.Viewport>
</Marquee.Root>
Examples
Reversed
Use the reverse prop on the Marquee.Root component to reverse the direction of the marquee.
Vertical Animation
To animate content along the Y axis, use the side prop and set it to bottom.
Speed
Use the speed prop to control the animation speed in pixels per second.
Pause On Interaction
Use the pauseOnInteraction prop to pause the animation when the user hovers or focuses the marquee.
Store
Use the Marquee.RootProvider and useMarquee hook to provide the marquee instance to the component and control the animation state programmatically.
Finite Loops
To loop the marquee a finite number of times, set the loopCount prop on Marquee.Root. Alternatively, use the onLoopComplete and onComplete callbacks to track the number of completed loops or when the animation fully finishes.
Loops completed: 0
Animations completed: 0
<Marquee.Root
loopCount={3}
onLoopComplete={() => {
/* handle loop completion */
}}
onComplete={() => {
/* handle animation end */
}}
>
{/* Marquee.Item elements */}
</Marquee.Root>
Edge Gradient
Render the Marquee.Edge component to apply an edge fade.
Multiple
Here's an example of how to render alternating marquee components.
Diagonal
Here's an example of how to animate content diagonally using the marquee component.
News Ticker
Here's an example of how to implement a news ticker with the marquee component.
Image Gallery
Here's an example of a 3D perspective image gallery with multiple vertical marquees scrolling in alternating directions.
Testimonials
You can display testimonials with the marquee component.
RTL Support
The marquee component supports RTL (right-to-left) layouts. Wrap the component with LocaleProvider to enable RTL mode.
Guide
CSS Variables
<Marquee.Root
style={{
'--leverui-marquee-duration': '30s',
'--leverui-marquee-delay': '0s',
'--leverui-marquee-loop-count': 'infinite',
'--leverui-marquee-edge-color': 'var(--leverui-colors-bg)',
'--leverui-marquee-edge-size': '20%',
}}
>
{/* ... */}
</Marquee.Root>
| Variable | Description | Default |
|---|---|---|
--leverui-marquee-duration | How long the animation takes | Computed |
--leverui-marquee-delay | How long to wait before the animation starts | 0s |
--leverui-marquee-loop-count | How many times the animation runs | infinite |
--leverui-marquee-edge-color | The color of the fade at the edges | var(--leverui-colors-bg) |
--leverui-marquee-edge-size | The size of the fade at the edges | 20% |
Props
| Prop | Default | Type | Description |
|---|---|---|---|
side | start | Side | Side the marquee scrolls towards. |
spacing | 1rem | string | Space between items. |
speed | 50 | number | Speed, in pixels per second. |
as | div | Native tag | HTML tag to render. |
asChild | — | Solid render function | Render your own element with the marquee's props. |
unstyled | — | boolean | Turn off the Lever UI styles. |
autoFill | false | boolean | Repeat the content until it fills the container. |
defaultPaused | false | boolean | Start paused. |
delay | 0 | number | Wait before the animation starts, in seconds. |
ids | — | Partial<{ root: string; viewport: string; content: (index: number) => string }> | Ids for the marquee's elements. For use with other components. |
loopCount | 0 | number | Number of loops. 0 loops forever. |
onComplete | — | () => void | Called when all loops finish. Only when loopCount is above 0. |
onLoopComplete | — | () => void | Called after each loop. |
onPauseChange | — | (details: PauseStatusDetails) => void | Called on pause or resume. |
paused | — | boolean | Whether the marquee is paused. |
pauseOnInteraction | false | boolean | Pause on hover or focus. |
reverse | false | boolean | Reverse the animation direction. |
translations | — | IntlTranslations | Translated messages. |
translations.root sets the accessible name of the moving region. Do not put
important information only in moving content, and respect reduced motion
settings. Edge fades must not hide item text that assistive technology needs.
Customize with CSS
Each part has a stable .leverui-marquee__* class. class and style work on
the root, viewport, content, item, and edge. unstyled on the root or a part
turns off its default styles. Behavior stays the same.
<Marquee.Root class="featured-marquee" spacing="24px">
{/* Marquee parts */}
</Marquee.Root>
.featured-marquee {
--leverui-marquee-edge-size: 12%;
--leverui-marquee-edge-color: var(--page-background);
--leverui-marquee-duration: 30s;
}
.featured-marquee .leverui-marquee__item {
padding-inline: 1rem;
}
The root also has --leverui-marquee-spacing. The measurement variables the
marquee sets inline are internal.











