Back to Chakra Ui

Marquee

apps/www/content/docs/components/marquee.mdx

0.3.0-beta3.5 KB
Original Source
<ExampleTabs name="marquee-auto-fill" />

Usage

js
import { Marquee } from "@chakra-ui/react"
jsx
<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.

<ExampleTabs name="marquee-reverse-direction" />

Vertical Animation

To animate content along the Y axis, use the side prop and set it to bottom.

<ExampleTabs name="marquee-vertical-animation" />

Speed

Use the speed prop to control the animation speed in pixels per second.

<ExampleTabs name="marquee-with-speed" />

Pause On Interaction

Use the pauseOnInteraction prop to pause the animation when the user hovers or focuses the marquee.

<ExampleTabs name="marquee-pause-interactions" />

Store

Use the Marquee.RootProvider and useMarquee hook to provide the marquee instance to the component and control the animation state programmatically.

<ExampleTabs name="marquee-with-store" />

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.

tsx
<Marquee.Root
  loopCount={3}
  onLoopComplete={() => {
    /* handle loop completion */
  }}
  onComplete={() => {
    /* handle animation end */
  }}
>
</Marquee.Root>
<ExampleTabs name="marquee-finite-loop" />

Edge Gradient

Render the Marquee.Edge component to apply an edge fade.

<ExampleTabs name="marquee-edge-gradient" />

Multiple

Here's an example of how to render alternating marquee components.

<ExampleTabs name="marquee-multiple" />

Diagonal

Here's an example of how to animate content diagonally using the marquee component.

<ExampleTabs name="marquee-diagonal" />

News Ticker

Here's an example of how to implement a news ticker with the marquee component.

<ExampleTabs name="marquee-news-ticker" />

Here's an example of a 3D perspective image gallery with multiple vertical marquees scrolling in alternating directions.

<ExampleTabs name="marquee-image-gallery" />

Testimonials

You can display testimonials with the marquee component.

<ExampleTabs name="marquee-with-testimonials" />

RTL Support

The marquee component supports RTL (right-to-left) layouts. Wrap the component with LocaleProvider to enable RTL mode.

<ExampleTabs name="marquee-rtl" />

Guide

CSS Variables

The marquee component exposes CSS variables that can be used to customize its behavior and appearance.

tsx
<Marquee.Root
  css={{
    "--marquee-duration": "30s",
    "--marquee-delay": "0s",
    "--marquee-loop-count": "infinite",
    "--marquee-edge-color": "colors.bg",
    "--marquee-edge-size": "20%",
  }}
>
</Marquee.Root>
VariableDescriptionDefault
--marquee-durationAnimation durationComputed
--marquee-delayAnimation delay before starting0s
--marquee-loop-countNumber of animation iterationsinfinite
--marquee-edge-colorColor for the edge gradient overlaycolors.bg
--marquee-edge-sizeSize of the edge gradient20%

Props

<PropTable component="Marquee" part="Root" />