Socket
Socket
Sign inDemoInstall

@uiw/react-back-top

Package Overview
Dependencies
6
Maintainers
2
Versions
171
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @uiw/react-back-top

BackTop component


Version published
Weekly downloads
182
increased by16.67%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

BackTop 返回顶部

Buy me a coffee Open in unpkg NPM Downloads npm version

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

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

基本用法

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>
  )
}

函数子组件

点击按钮滚动到顶部

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>
  )
}

组件子节点

点击按钮滚动到顶部

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/String0
offsetTop是否始终显示组件Number0
showBelow滚动距离多少时显示组件Number1
clickable是否可以点击Booltrue
speed滚动速度Number50
fixed是否固定,默认trueBooltrue
styleCSS样式Object-
classNameCSS类名称String-
onClick点击回调Function-

Keywords

FAQs

Last updated on 29 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc