Marquee
A continuous scrolling component for displaying content in a seamless loop.
Anatomy
<Marquee.Root>
<Marquee.Edge />
<Marquee.Viewport>
<Marquee.Content>
<Marquee.Item />
</Marquee.Content>
</Marquee.Viewport>
</Marquee.Root>
Examples
Auto Fill
Set autoFill to duplicate content until it fills the viewport. spacing sets the gap between copies.
Reverse
Set reverse to flip the scroll direction.
Vertical
Set side="bottom" or side="top" for a vertical marquee.
Speed
Set speed in pixels per second.
Pause on Interaction
Set pauseOnInteraction to pause on hover or focus. This helps accessibility.
Programmatic Control
Use the useMarquee hook with Marquee.RootProvider to control playback through the API.
Marquee.RootProviderreplacesMarquee.Root. Don't use both.
Loops
Set loopCount to run a fixed number of loops. onLoopComplete fires after each loop and onComplete after the last.
Edges
Add Marquee.Edge to fade the start and end of the scroll area.
Guides
Content Animation
Marquee needs CSS keyframes for horizontal and vertical scrolling:
@keyframes marqueeX {
from {
transform: translateX(0);
}
to {
transform: translateX(var(--marquee-translate));
}
}
@keyframes marqueeY {
from {
transform: translateY(0);
}
to {
transform: translateY(var(--marquee-translate));
}
}
The component applies marqueeX or marqueeY based on direction and uses --marquee-translate to loop without a jump.
Style parts through their data attributes:
[data-marquee-root]- The root container[data-marquee-viewport]- The scrolling viewport[data-marquee-content]- The content wrapper (receives animation)[data-marquee-item]- Individual marquee items[data-marquee-edge]- Edge gradient overlays
Best Practices
- Enable pause-on-interaction: Set
pauseOnInteractionso users can pause on hover or focus. - Use descriptive labels: Give an
aria-labelthat names the content (e.g., "Partner logos"). - Avoid for critical information: Moving text is hard to read. Show essential content statically.
API Reference
Props
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
autoFill | false | booleanWhether to automatically duplicate content to fill the container. |
defaultPaused | false | booleanWhether the marquee is paused by default. |
delay | 0 | numberThe delay before the animation starts (in seconds). |
ids | ElementIdsThe ids of the elements in the marquee. Useful for composition. | |
loopCount | 0 | numberThe number of times to loop the animation (0 = infinite). |
onComplete | () => voidFunction called when the marquee completes all loops and stops. Only fires for finite loops (loopCount > 0). | |
onLoopComplete | () => voidFunction called when the marquee completes one loop iteration. | |
onPauseChange | (details: PauseStatusDetails) => voidFunction called when the pause status changes. | |
paused | booleanWhether the marquee is paused. | |
pauseOnInteraction | false | booleanWhether to pause the marquee on user interaction (hover, focus). |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
reverse | false | booleanWhether to reverse the animation direction. |
side | 'start' | SideThe side/direction the marquee scrolls towards. |
spacing | '1rem' | stringThe spacing between marquee items. |
speed | 50 | numberThe speed of the marquee animation in pixels per second. |
translations | IntlTranslationsThe localized messages to use. |
| Attribute | Description |
|---|---|
[data-marquee-root] | <uid> |
[data-state] | "paused" | "idle" |
[data-orientation] | The orientation of the marquee |
[data-paused] | Present when paused |
| CSS Variable | Description |
|---|---|
--marquee-duration | The marquee duration value for the Root |
--marquee-spacing | The marquee spacing value for the Root |
--marquee-delay | The marquee delay value for the Root |
--marquee-loop-count | The marquee loop count value for the Root |
--marquee-translate | The marquee translate value for the Root |
Content
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<MarqueeContentState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-marquee-content] | <uid> |
[data-index] | The index of the item |
[data-orientation] | The orientation of the content |
[data-side] | The side of the trigger that the content is positioned on |
[data-reverse] | |
[data-clone] |
Edge
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
side | SideThe side where the edge gradient should appear. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-marquee-edge] | <uid> |
[data-side] | The side of the trigger that the edge is positioned on |
[data-orientation] | The orientation of the edge |
Item
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseMarqueeReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Viewport
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-marquee-viewport] | <uid> |
[data-orientation] | The orientation of the viewport |
[data-side] | The side of the trigger that the viewport is positioned on |
Context
API
| Property | Type |
|---|---|
paused | booleanWhether the marquee is currently paused. |
orientation | "horizontal" | "vertical"The current orientation of the marquee. |
side | SideThe current side/direction of the marquee. |
multiplier | numberThe multiplier for auto-fill. Indicates how many times to duplicate content. When autoFill is enabled and content is smaller than container, this returns the number of additional copies needed. Otherwise returns 1. |
contentCount | numberThe total number of content elements to render (original + clones). Use this value when rendering your content in a loop. |
pause | VoidFunctionPause the marquee animation. |
resume | VoidFunctionResume the marquee animation. |
togglePause | VoidFunctionToggle the pause state. |
restart | VoidFunctionRestart the marquee animation from the beginning. |
getRootState | () => RootStateReturns the state of the root |
getContentState | (props: ContentProps) => ContentStateReturns the state of a content instance |