# react-scroll-up

> React component to render element for scroll to top of page

Latest version **1.4.0** (published 2022-12-16) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2022-12-16 |
| First published | 2015-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 27 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 176 |
| Author | Milos Janda |
| Maintainers | milosjanda |
| Keywords | scroll, scrollUp, scrollToTop, animation, effects, react, react-component |

## Links

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

## Dependencies (4)

- [prop-types](https://npm.io/package/prop-types.md) ^15.5.8
- [object-assign](https://npm.io/package/object-assign.md) ^4.0.1
- [tween-functions](https://npm.io/package/tween-functions.md) ^1.1.0
- [detect-passive-events](https://npm.io/package/detect-passive-events.md) ^2.0.2

## 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.4.0 (latest) — 2022-12-16
- 1.3.7 — 2020-11-29
- 1.3.6 — 2020-11-29
- 1.3.5 — 2020-10-06
- 1.3.4 — 2020-09-30
- 1.3.3 — 2017-10-05
- 1.3.2 — 2017-09-29
- 1.3.1 — 2017-06-27
- 1.3.0 — 2017-05-02
- 1.2.3 — 2017-04-29
- 1.2.2 — 2017-04-25
- 1.2.1 — 2017-01-12
- 1.2.0 — 2017-01-11
- 1.1.5 — 2016-05-25
- 1.1.4 — 2016-04-29
- … 9 more at https://npm.io/package/react-scroll-up/versions

## README

# react-scroll-up
[![npm version](https://badge.fury.io/js/react-scroll-up.svg)](https://badge.fury.io/js/react-scroll-up)
[![License](https://img.shields.io/npm/l/react-scroll-up.svg)](https://github.com/milosjanda/react-scroll-up/blob/master/LICENSE)
[![Dependency Status](https://img.shields.io/david/milosjanda/react-scroll-up.svg)]()
[![peerDependency Status](https://img.shields.io/david/peer/milosjanda/react-scroll-up.svg)]()
[![Build status](https://travis-ci.org/milosjanda/react-scroll-up.svg?branch=master)](https://travis-ci.org/milosjanda/react-scroll-up)
[![Downloads](https://img.shields.io/npm/dm/react-scroll-up.svg)]()

React component to add custom button (it can be something what you want) for scroll to top of page.

Library uses [requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame),
if you want better browser compatibility (IE9 and older), you can use something like  [https://gist.github.com/paulirish/1579671].


## Install

```npm
npm install react-scroll-up
```

## How to use it

[Live demo](http://milosjanda.github.io/react-scroll-up/)

You have to define children element, for example `<span>UP</span>`

```jsx
<ScrollToTop showUnder={160}>
  <span>UP</span>
</ScrollToTop>
```

## Parameters

### showUnder:number in px (required) 

What position (and below) the button will be displayed.

### topPosition:number in px (optional)

default: 0

The position to which the scrollbar be moved after clicked.

### easing:string (optional)

default: easeOutCubic

Type of scrolling easing. You can specify some of this type of easing: https://github.com/chenglou/tween-functions

In graphical representation: http://sole.github.io/tween.js/examples/03_graphs.html

### duration:number in miliseconds (optional)

default: 250

Time to reach the `topPosition`

### onShow:function (optional)

Callback function to be called when the button is being displayed.

### onHide:function (optional)

Callback function to be called when the button is being hidden.

### style:object (optional)

default:  

```javascript
{
  position: 'fixed',
  bottom: 50,
  right: 30,
  cursor: 'pointer',
  transitionDuration: '0.2s',
  transitionTimingFunction: 'linear',
  transitionDelay: '0s'
}
```

You can specify you own style and position of the button.

Hide/show button is based on opacity, so this styles `opacity` and `transitionProperty` will be all time overwrite.

If you can positioned button to left site, you have to reset css property `right: 'auto'`, and similar.

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