![]() |
VOOZH | about |
BackTop is a component in Ant Design that provides a button when the user has scrolled through the page to go back to the top of the page without the need to scroll back to the top. It will take the user to the top of the page with a smooth scrolling animation.
Ant Design Library has this component pre-built, and it is very easy to integrate as well. We can use this BackTop component using the following approach easily.
<BackTop> Scroll to Top </BackTop>
Step 1: Create a React application using the following command.
npx create-react-app demo
Step 2: After creating your project folder i.e. demo, move to it using the following command.
cd demo
Step 3: After creating the ReactJS application, Install the antd library using the following command.
npm install antd
Project Structure:
👁 ImageExample: Now write the following code in filename App.js.
Running the application: Run the application by using the following command.
npm start
Output: Now open your browser and go to http://localhost:3000/, You will see the following output.
👁 Image