How to rotate a particular string onScroll in ReactJS ?
Last Updated :
26 Jul, 2024
In, this article, we will see how we can rotate a text while Scrolling to give a nice user experience by using an npm package react-scroll-rotate.
Prerequisites:
Syntax:
<ScrollRotate> </ScrollRotate>
We wrap the text within these tags which we want to show effects.
Steps to Create the React Application And Installing Module:
Step 1: Create the react project folder, for that open the terminal, and write the command
npm create-react-app project
Step 2: After creating your project folder(i.e. project), move to it by using the following command.
cd project
Step 3:Â now install the dependency react-scroll-rotate by using the following command:
npm i react-scroll-rotate
Project Structure:

The updated dependencies in package.json file will look like:
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-scroll-rotate": "^0.0.7",
"web-vitals": "^2.1.4",
}
Example: In the App.js file, we are creating a simple welcome message where we will wrap the word geek within the ScrollRotate tags, to use it first we have imported it from react-scroll-rotate
JavaScript
import { ScrollRotate } from 'react-scroll-rotate';
function App() {
return (
<div className="App">
<div style={{ marginTop: 400 }} >
<h1 align="center">Hey!
<ScrollRotate>
<span style={{ color: "red" }}> Geek </span>
</ScrollRotate> Welcome To Geekforgeeks
</h1>
</div>
<div style={{ marginTop: 800 }} />
</div>
);
}
export default App;
Step to Run Application: Run the application using the following command from the root directory of the project.
npm start
Output:
Similar Reads
How to scroll to a particular element or skip to content in React JS ? In this article, we will learn about how to scroll or skip a particular element in React JS, We can do this using React hook useRef and React styled-components. Prerequisite:ReactReact Styled Components.React useRef hooks.Approach to implement particular element scroll/skip: It is used to scroll to
4 min read
How to Create Scroll Indicator using ReactJS ? Scroll Indicator in React JS refers to a representation of the length of the page visited or present on the screen. It shows the amount the pages that have been scrolled. PrerequisiteNode.js & npm React JSstyled-componentsReact JS useState() hooks.Approach to create Scroll IndicatorTo create a S
2 min read
React Suite Icon Flip and rotate A React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application. In this article, we'll learn about React suite Icon Flip and Ro
3 min read
Create a scroll status in ReactJS using Material-UI Progress bars at the top, showing scroll status are very common nowadays in webpages. Also, ReactJS and Material-UI go pretty well along with each other, React-JS being the most popular JavaScript framework for building UI components and Material-UI a library that provides various useful and reusabl
3 min read
How to Make Text Blink in ReactJS ? In this article, we are going to learn about making a text blink in React. Making text blink in React refers to the process of creating a visual effect where text repeatedly alternates between being visible and invisible, creating a flashing or blinking appearance, often achieved through CSS animati
3 min read