# react-scroll-up-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

Latest version **1.0.0** (published 2021-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-scroll-up-to-top
pnpm add react-scroll-up-to-top
yarn add react-scroll-up-to-top
bun add react-scroll-up-to-top
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-10-25 |
| First published | 2021-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hoang Le |
| Maintainers | hoangle4 |
| Keywords | react, top, scroll, scroll-to-top, scroll up |

## Links

- npm: https://www.npmjs.com/package/react-scroll-up-to-top
- Repository: https://github.com/hoangle4/react-scroll-to-top
- Homepage: https://github.com/hoangle4/react-scroll-to-top#readme
- Issues: https://github.com/hoangle4/react-scroll-to-top/issues
- npm.io page: https://npm.io/package/react-scroll-up-to-top

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2021-10-25

## README

# 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](https://nodei.co/npm/react-scroll-to-top.png)](https://nodei.co/npm/react-scroll-to-top/)

## Live demo
[A live demo can be found here](https://codesandbox.io/s/react-scroll-to-top-demo-rmuvx?file=/src/App.js)

## Installation

Run `npm i react-scroll-to-top`

## Usage

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

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

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

## Props

| Prop      | Type    | Description                                  | Default       |
| --------- | ------- | -------------------------------------------- | ------------- |
| smooth    | boolean | Whether to use smooth scrolling*             | false         |
| top       | number  | Height after page scroll to be visible       | 20            |
| color     | string  | The SVG icon fill color                      | "black"       |
| svgPath   | string  | The SVG icon path d attribute                | An arrow path |
| viewBox   | string  | The SVG icon viewBox attribute               | "0 0 256 256" |
| component | any     | Component to override SVG icon. See examples |               |
| style     | Object  | Object to add/override styling               |               |
| className | string  | Classname to completely override styling     |               |

Smooth scrolling uses a newer `window.scrollTo` implementation.\
[Check out its support in browsers at MDN web docs](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo).

## Examples  
[With custom SVG path](https://codesandbox.io/s/react-scroll-to-top-svg-path-y2ztc?file=/src/App.js)  
[With custom SVG component](https://codesandbox.io/s/react-scroll-to-top-custom-svg-or74g?file=/src/App.js)  
[With custom DOM element](https://codesandbox.io/s/react-scroll-to-top-custom-dom-element-y7j0f?file=/src/App.js)  

## Types

Written in TypeScript, no need for @types installation

---
_Source: https://npm.io/package/react-scroll-up-to-top · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
