Installation
If you're using npm, in the command prompt run:
npm install react-fast-marquee --saveIf you're using yarn, run:
yarn add react-fast-marqueeUsage
To use the component, first import it into your file:
import Marquee from "react-fast-marquee";Then wrap the <Marquee> tags around any component or text you'd like to slide.
<Marquee>
I can be a React component, multiple React components, or just some text.
</Marquee>A sample file might look like this:
import React from "react";
import MyComponent from "../components/MyComponent";
import Marquee from "react-fast-marquee";
const App = () => (
<Marquee>
<MyComponent />
<MyComponent />
<MyComponent />
</Marquee>
);
export default App;Props
styleThe inline style for the container div.
| Type | Default | Required |
|---|---|---|
| CSSProperties | {} | No |
classNameThe name of the css class to style the container div.
| Type | Default | Required |
|---|---|---|
| string | "" | No |
autoFillWhether to automatically fill blank space in the marquee with copies of the children or not.
| Type | Default | Required |
|---|---|---|
| boolean | false | No |
playWhether to play or pause the marquee.
| Type | Default | Required |
|---|---|---|
| boolean | true | No |
pauseOnHoverWhether to pause the marquee when hovered.
| Type | Default | Required |
|---|---|---|
| boolean | false | No |
pauseOnClickWhether to pause the marquee when clicked.
| Type | Default | Required |
|---|---|---|
| boolean | false | No |
directionThe direction the marquee is sliding. Warning: Vertical marquees are currently experimental and may be buggy. Please swap the values of the marquee's height and width when setting them
| Type | Default | Required |
|---|---|---|
| "left" | "right" | "up" | "down" | left | No |
speedThe speed calculated as pixels/second.
| Type | Default | Required |
|---|---|---|
| number | 50 | No |
delayThe duration to delay the animation after render, in seconds.
| Type | Default | Required |
|---|---|---|
| number | 0 | No |
loopThe number of times the marquee should loop, 0 is equivalent to infinite.
| Type | Default | Required |
|---|---|---|
| number | 0 | No |
gradientWhether to show the gradient or not.
| Type | Default | Required |
|---|---|---|
| boolean | false | No |
gradientColorThe color of the gradient.
| Type | Default | Required |
|---|---|---|
| string | white | No |
gradientWidthThe width of the gradient on either side.
| Type | Default | Required |
|---|---|---|
| number | string | 200 | No |
onFinishA callback for when the marquee finishes scrolling and stops. Only calls if loop is non-zero.
| Type | Default | Required |
|---|---|---|
| function | {() => void} | No |
onCycleCompleteA callback for when the marquee finishes a loop. Does not call if maximum loops are reached (use onFinish instead).
| Type | Default | Required |
|---|---|---|
| {() => void} | null | No |
childrenThe children rendered inside the marquee.
| Type | Default | Required |
|---|---|---|
| ReactNode | null | Yes |