Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-scroll-to-top

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll-to-top

A lightweight and customizable button component that scrolls to the top of a page when pressed The button is only visible once a certain height has been reached on the page

  • 1.0.8
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-scroll-to-top

A lightweight and customizable button component that scrolls to the top of a page when pressed
The button is only visible once a certain height has been reached on the page

NPM

Live demo

A live demo can be found here

Installation

Run npm i react-scroll-to-top

Usage

Import and then include <ScrollToTop /> anywhere in your render/return function:

import ScrollToTop from "react-scroll-to-top";

function CoolPage() {
  return (
    <div>
      <ScrollToTop smooth />
      <h1>Hello, world!</h1>
    </div>
  );
}

Props

PropTypeDescriptionDefault
smoothbooleanWhether to use smooth scrolling*false
topnumberHeight after page scroll to be visible20
colorstringThe SVG icon fill color"black"
svgPathstringThe SVG icon path d attributeAn arrow path
widthstringThe SVG icon width"28"
heightstringThe SVG icon height"28"
viewBoxstringThe SVG icon viewBox attribute"0 0 256 256"
componentanyComponent to override SVG icon. See examples
styleObjectObject to add/override styling
classNamestringClassname to completely override styling

Smooth scrolling uses a newer window.scrollTo implementation.
Check out its support in browsers at MDN web docs.

Examples

With custom SVG path
With custom SVG component
With custom DOM element

Types

Written in TypeScript, no need for @types installation

Keywords

FAQs

Package last updated on 09 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc