# @uiw/react-back-top

> BackTop component

Latest version **4.22.3** (published 2023-11-29) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.22.3 |
| Published | 2023-11-29 |
| First published | 2020-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 740 |
| Author | Kenny Wong |
| Maintainers | uiwjs, wcjiang |
| Keywords | back-top, react-back-top, design, uiw, uiw-react, react.js, react, react-component, component, components, ui, css, uikit, react-ui, framework, front-end, frontend |

## Links

- npm: https://www.npmjs.com/package/@uiw/react-back-top
- Repository: https://github.com/uiwjs/uiw
- Homepage: https://uiwjs.github.io/#/components/back-top
- Issues: https://github.com/uiwjs/uiw/issues
- Funding: https://jaywcjlove.github.io/#/sponsor
- npm.io page: https://npm.io/package/@uiw/react-back-top

## Dependencies (1)

- [@uiw/utils](https://npm.io/package/@uiw/utils.md) ^4.22.3

## Alternatives

- [@progress/kendo-ooxml](https://npm.io/package/@progress/kendo-ooxml.md) — 152.1K weekly downloads
- [@progress/kendo-react-ripple](https://npm.io/package/@progress/kendo-react-ripple.md) — 8.0K weekly downloads
- [@progress/kendo-react-orgchart](https://npm.io/package/@progress/kendo-react-orgchart.md) — 4.3K weekly downloads
- [@praxisui/dynamic-fields](https://npm.io/package/@praxisui/dynamic-fields.md) — 2.4K weekly downloads
- [@mesalvo/react-ui](https://npm.io/package/@mesalvo/react-ui.md) — 1.7K weekly downloads

## Recent versions

- 4.22.3 (latest) — 2023-11-29
- 5.0.0-bate.2.1 (bate) — 2023-03-10
- 4.22.2 — 2023-11-09
- 4.22.1 — 2023-11-08
- 4.22.0 — 2023-09-19
- 4.21.28 — 2023-05-05
- 4.21.27 — 2023-04-21
- 4.21.26 — 2023-04-20
- 4.21.25 — 2023-03-14
- 4.21.24 — 2023-03-08
- 5.0.0-bate.2.0 — 2023-03-02
- 4.21.23 — 2022-12-21
- 4.21.22 — 2022-12-19
- 4.21.21 — 2022-12-19
- 5.0.0-bate-19 — 2022-12-12
- … 156 more at https://npm.io/package/@uiw/react-back-top/versions

## README

BackTop 返回顶部
===

[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor)
[![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-back-top/file/README.md)
[![NPM Downloads](https://img.shields.io/npm/dm/@uiw/react-back-top.svg?style=flat)](https://www.npmjs.com/package/@uiw/react-back-top)
[![npm version](https://img.shields.io/npm/v/@uiw/react-back-top.svg?label=@uiw/react-back-top)](https://npmjs.com/@uiw/react-back-top)

返回页面顶部的操作按钮。

```jsx
import { BackTop } from 'uiw';
// or
import BackTop from '@uiw/react-back-top';
```

## 基本用法

```jsx mdx:preview
import React from 'react';
import { BackTop } from 'uiw';

export default function Demo() {
  return (
    <div>
      <div>滚动滚动条，【快看右下角】，显示返回顶部按钮。</div>
      <BackTop
        style={{ backgroundColor: 'red', color: '#fff' }}
        step={500}
        speed={10}
        content={<div>Top</div>}
      />
    </div>
  )
}
```

## 函数子组件

点击按钮滚动到顶部

```jsx mdx:preview
import React from 'react';
import { BackTop, Button } from 'uiw';

export default function Demo() {
  return (
    <BackTop
      fixed={false}
      step={500}
      clickable={false}
      speed={10}
    >
      {({ percent, scrollToTop }) => (
        <Button onClick={() => scrollToTop() } type="success">点击滚动到顶部{`${percent}%`}</Button>
      )}
    </BackTop>
  )
}
```

## 组件子节点

点击按钮滚动到顶部

```jsx mdx:preview
import React from 'react';
import { BackTop, Button } from 'uiw';

export default function Demo() {
  return (
    <BackTop
      fixed={false}
      step={500}
      speed={10}
    >
      <Button type="success">点击滚动到顶部</Button>
    </BackTop>
  )
}
```

## Params

| 参数 | 说明 | 类型 | 默认值 |
|--------- |-------- |--------- |-------- |
| content | 滚动到顶部按钮内容 | ReactNode/String | `0` |
| offsetTop | 是否始终显示组件 | Number | `0` |
| showBelow | 滚动距离多少时显示组件 | Number | `1` |
| clickable | 是否可以点击 | Bool | `true` |
| speed | 滚动速度 | Number | `50` |
| fixed | 是否固定，默认`true` | Bool | `true` |
| style | CSS样式 | Object | - |
| className | CSS类名称 | String | - |
| onClick | 点击回调 | Function | - |

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