# @uiw/react-back-to-top

> A minimal lightweight react component for adding a nice scroll up (back to top) button with onScroll progress.

Latest version **1.2.4** (published 2026-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @uiw/react-back-to-top
pnpm add @uiw/react-back-to-top
yarn add @uiw/react-back-to-top
bun add @uiw/react-back-to-top
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2026-05-30 |
| First published | 2022-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 48.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 6 |
| Author | Kenny Wong |
| Maintainers | wcjiang, uiwjs |
| Keywords | react-back-to-top, react.js, react, back-to-top, uiw, uiw-react, react-component, component, components, ui, css, uikit, framework |

## Links

- npm: https://www.npmjs.com/package/@uiw/react-back-to-top
- Repository: https://github.com/uiwjs/react-back-to-top
- Homepage: https://uiwjs.github.io/react-back-to-top
- Issues: https://github.com/uiwjs/react-back-to-top/issues
- npm.io page: https://npm.io/package/@uiw/react-back-to-top

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.2.4 (latest) — 2026-05-30
- 1.2.3 — 2023-06-06
- 1.2.2 — 2023-05-07
- 1.2.1 — 2022-09-08
- 1.2.0 — 2022-08-28
- 1.1.2 — 2022-08-28
- 1.1.1 — 2022-08-27
- 1.0.0 — 2022-08-27

## README

<div markdown="1">
  <sup>Using <a href="https://wangchujiang.com/#/app" target="_blank">my app</a> is also a way to <a href="https://wangchujiang.com/#/sponsor" target="_blank">support</a> me:</sup>
  <br>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6766860898" title="Zipora: Zip/RAR/7Z Unarchiver"><img alt="Zipora: Zip/RAR/7Z Unarchiver" height="52" src="https://wangchujiang.com/appicon/zipora.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6758053530" title="Scap: Screenshot & Markup Edit for macOS"><img alt="Scap: Screenshot & Markup Edit" height="52" src="https://wangchujiang.com/appicon/scap.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6757317079" title="Screen Test for macOS"><img alt="Screen Test" height="52" src="https://wangchujiang.com/appicon/screen-test.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6755948110" title="Deskmark for macOS"><img alt="Deskmark" height="52" src="https://wangchujiang.com/appicon/deskmark.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6500434773" title="Keyzer for macOS"><img alt="Keyzer" height="52" src="https://wangchujiang.com/appicon/keyzer.png"></a>
  <a target="_blank" href="https://github.com/jaywcjlove/vidwall-hub" title="Vidwall Hub for macOS"><img alt="Vidwall Hub" height="52" src="https://wangchujiang.com/appicon/vidwall-hub.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6752624705" title="VidCrop for macOS"><img alt="VidCrop" height="52" src="https://wangchujiang.com/appicon/vidcrop.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6747587746" title="Vidwall for macOS"><img alt="Vidwall" height="52" src="https://wangchujiang.com/appicon/vidwall.png"></a>
  <a target="_blank" href="https://wangchujiang.com/mousio-hint/" title="Mousio Hint for macOS"><img alt="Mousio Hint" height="52" src="https://wangchujiang.com/appicon/mousio-hint.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6746747327" title="Mousio for macOS"><img alt="Mousio" height="52" src="https://wangchujiang.com/appicon/mousio.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6745227444" title="Musicer for macOS"><img alt="Musicer" height="52" src="https://wangchujiang.com/appicon/musicer.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6743841447" title="Audioer for macOS"><img alt="Audioer" height="52" src="https://wangchujiang.com/appicon/audioer.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6744690194" title="FileSentinel for macOS"><img alt="FileSentinel" height="52" src="https://wangchujiang.com/appicon/file-sentinel.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6743495172" title="FocusCursor for macOS"><img alt="FocusCursor" height="52" src="https://wangchujiang.com/appicon/focus-cursor.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6742680573" title="Videoer for macOS"><img alt="Videoer" height="52" src="https://wangchujiang.com/appicon/videoer.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6740425504" title="KeyClicker for macOS"><img alt="KeyClicker" height="52" src="https://wangchujiang.com/appicon/key-clicker.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6739052447" title="DayBar for macOS"><img alt="DayBar" height="52" src="https://wangchujiang.com/appicon/daybar.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6739444407" title="Iconed for macOS"><img alt="Iconed" height="52" src="https://wangchujiang.com/appicon/iconed.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6737160756" title="Menuist for macOS"><img alt="Menuist" height="52" src="https://wangchujiang.com/appicon/rightmenu-master.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6723903021" title="Paste Quick for macOS"><img alt="Quick RSS" height="52" src="https://wangchujiang.com/appicon/paste-quick.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6670696072&platform=mac" title="Quick RSS for macOS/iOS"><img alt="Quick RSS" height="52" src="https://wangchujiang.com/appicon/quick-rss.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6670167443" title="Web Serve for macOS"><img alt="Web Serve" height="52" src="https://wangchujiang.com/appicon/web-serve.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6503953628&platform=mac" title="Copybook Generator for macOS/iOS"><img alt="Copybook Generator" height="52" src="https://wangchujiang.com/appicon/copybook-generator.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6471227008&platform=mac" title="DevTutor for macOS/iOS"><img alt="DevTutor for SwiftUI" height="52" src="https://wangchujiang.com/appicon/devtutor.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6479819388&platform=mac" title="RegexMate for macOS/iOS"><img alt="RegexMate" height="52" src="https://wangchujiang.com/appicon/regex-mate.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6479194014&platform=mac" title="Time Passage for macOS/iOS"><img alt="Time Passage" height="52" src="https://wangchujiang.com/appicon/time-passage.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6478772538" title="IconizeFolder for macOS"><img alt="Iconize Folder" height="52" src="https://wangchujiang.com/appicon/iconize-folder.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6478511402&platform=mac" title="Textsound Saver for macOS/iOS"><img alt="Textsound Saver" height="52" src="https://wangchujiang.com/appicon/textsound-saver.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6476924627" title="Create Custom Symbols for macOS"><img alt="Create Custom Symbols" height="52" src="https://wangchujiang.com/appicon/create-custom-symbols.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6476452351" title="DevHub for macOS"><img alt="DevHub" height="52" src="https://wangchujiang.com/appicon/devhub.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6476400184" title="Resume Revise for macOS"><img alt="Resume Revise" height="52" src="https://wangchujiang.com/appicon/resume-revise.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6472593276" title="Palette Genius for macOS"><img alt="Palette Genius" height="52" src="https://wangchujiang.com/appicon/palette-genius.png"></a>
  <a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6470879005" title="Symbol Scribe for macOS"><img alt="Symbol Scribe" height="52" src="https://wangchujiang.com/appicon/symbol-scribe.png"></a>
</div>
<hr>

<!--rehype:ignore:start-->
React Back To Top
===
<!--rehype:ignore:end-->

[![Buy me a coffee](https://img.shields.io/badge/Buy_Me_a_Coffee-ffdd00?logo=buy-me-a-coffee&logoColor=black)](https://jaywcjlove.github.io/#/sponsor)
[![Follow On X](https://img.shields.io/badge/Follow%20on%20X-333333?logo=x&logoColor=white)](https://x.com/jaywcjlove)
[![Coverage Status](https://uiwjs.github.io/react-back-to-top/badges.svg)](https://uiwjs.github.io/react-back-to-top/coverage/lcov-report/)
[![NPM Downloads](https://img.shields.io/npm/dm/@uiw/react-back-to-top.svg?style=flat)](https://www.npmjs.com/package/@uiw/react-back-to-top)
[![NPM Version](https://img.shields.io/npm/v/@uiw/react-back-to-top.svg)](https://www.npmjs.com/package/@uiw/react-back-to-top)

A minimal lightweight react component for adding a nice scroll up (back to top) button with onScroll progress.

[![React Back To Top](https://user-images.githubusercontent.com/1680273/187046411-677c24c4-043a-4505-b2ef-6bd1eb7ad311.png)](https://uiwjs.github.io/react-back-to-top/)

## Install

Not dependent on uiw.

```bash
npm install @uiw/react-back-to-top --save
```

## Usage

```jsx mdx:preview
import React from "react";
import BackToUp from '@uiw/react-back-to-top';

export default function App() {
  return (
    <div className="container">
      <span style={{ color: 'red' }}>
        Please check the button in the lower right corner of your web page.
      </span>
      <BackToUp>Top</BackToUp>
    </div>
  );
}
```

Support adding `<BackToUp />` buttons to the partial scrollable area.

```jsx mdx:preview
import React, { useRef, useEffect, useState } from "react";
import BackToUp from '@uiw/react-back-to-top';
import styled from 'styled-components';

const Warpper = styled.div`
  overflow: auto;
  white-space: normal;
  width: 300px;
  height: 300px;
  &::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 7px;
    background: #00000038;
  }
  &::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: #595959;
  }
  p {
    display: inline;
    background: rgba(0, 0, 0, 0.12);
    color: transparent;
  }
`;

export default function App() {
  const $dom = useRef(null);
  const [element, setElement]= useState();
  useEffect(() => setElement($dom.current), [])
  return (
    <Warpper ref={$dom}>
      <h1>React simple scroll up with onScroll progress</h1>
      <p>React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.</p>
      <h2>Scroll down ↓</h2>
      <p>Declarative views make your code more predictable and easier to debug.</p>
      <h2 style={{ height: 1200 }}>Scroll down ↓</h2>
      <p>Build encapsulated components that manage their own state, then compose them to make complex UIs. </p>
      <p>Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.</p>
      <BackToUp top={0} element={$dom.current} style={{ float: 'right' }}>Top</BackToUp>
    </Warpper>
  );
}
```

Custom button style.

```jsx mdx:preview
import React, { useRef, useEffect, useState } from "react";
import BackToUp from '@uiw/react-back-to-top';
import styled from 'styled-components';

const Warpper = styled.div`
  overflow: auto;
  white-space: normal;
  width: 300px;
  height: 300px;
  &::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 7px;
    background: #00000038;
  }
  &::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: #595959;
  }
  p {
    display: inline;
    background: rgba(0, 0, 0, 0.12);
    color: transparent;
  }
`;

export default function App() {
  const $dom = useRef(null);
  const [element, setElement]= useState();
  useEffect(() => setElement($dom.current), [])
  return (
    <Warpper ref={$dom}>
      <h1>React simple scroll up with onScroll progress</h1>
      <p>React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.</p>
      <h2>Scroll down ↓</h2>
      <p>Declarative views make your code more predictable and easier to debug.</p>
      <h2>Scroll down ↓</h2>
      <p>Build encapsulated components that manage their own state, then compose them to make complex UIs. </p>
      <p>Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.</p>
      <BackToUp top={0} hideProgress element={$dom.current} style={{ float: 'right' }}>
        <div style={{ border: '1px solid red', color: 'red', background: '#ffeb3b' }}>
          Top
        </div>
      </BackToUp>
    </Warpper>
  );
}
```

## Props

```ts
import React from 'react';
export interface BackToUpProps extends React.AllHTMLAttributes<HTMLDivElement> {
  prefixCls?: string;
  /** Scroll bar area @default document.documentElement **/
  element?: HTMLElement;
  /** Whether to use smooth scrolling* @default true */
  smooth?: boolean;
  /** Classname to add/override styling (note, !important for overrides might be needed) */
  className?: string;
  /** Object to add/override styling */
  style?: React.CSSProperties;
  /** Height after page scroll to be visible @default 120 **/
  top?: number;
  /** The Button width & height @default 35 */
  size?: number;
  /** the width of the progress bar */
  strokeWidth?: number;
  /** hide progress icon */
  hideProgress?: boolean;
}
export default function BackToUp(props?: BackToUpProps): JSX.Element;
```

## Development

1. Install

```bash
npm install
```

2. To develop, run the self-reloading build:

```bash
npm run build  # Compile packages      📦 @uiw/react-back-to-top
npm run watch  # Real-time compilation 📦 @uiw/react-back-to-top
```

3. Run Document Website Environment:

```bash
npm run start
```

4. To contribute, please fork repos, add your patch and tests for it (in the `test/` folder) and submit a pull request.

```
npm run test
```

## Contributors

As always, thanks to our amazing contributors!

<a href="https://github.com/uiwjs/react-back-to-top/graphs/contributors">
  <img src="https://uiwjs.github.io/react-back-to-top/CONTRIBUTORS.svg" />
</a>

Made with [github-action](https://github.com/jaywcjlove/github-action-contributors).

## License

Licensed under the MIT License.

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