1.0.2 • Published 3 years ago

react-custom-back-to-top-button v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

react-custom-back-to-top-button

Back to top button package allows you to set a button that can be shaped the way you want and put any icon in it

Install

$ npm i react-custom-back-to-top-button

or

$ yarn add react-custom-back-to-top-button

Dependencies

  • @material-ui/core
  • @material-ui/icons

:exclamation: You do not need to install these two dependencies, they will be installed automatically.

Use

import React, { Fragment } from 'react';
import BackToTop from 'react-custom-back-to-top-button';

const App = () => {
 return (
   <Fragment>
     // Your some code
     <BackToTop/>
   </Fragment>
 );
};

export default App;

Change icon

You can pass the icon you like as props from fontawesome icons.

Example code:

import React, { Fragment } from 'react';
import BackToTop from 'react-custom-back-to-top-button';

const App = () => {
  return (
    <Fragment>
      // Your some code
      <BackToTop icon={<i className='fas fa-sort-up'></i>}/>
    </Fragment>
  );
};

export default App;

To use fontawesome icons, don't forget to add the fontawesome link in the <head> </head> section of your index.html file in the public folder. Add this link if you want:

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">

Props

PropTypeDefaultDescription
showIconbooleantrueShow / Hide icon
iconelement<KeyboardArrowUpIcon style={{fontSize: 25}}/>You can use the icon of your choice as shown in the example code.
toShownumber300To show the button by the value of scrollY

Style

PropTypeDefaultDescription
fontSizenumber16Sets the size of the text you add to the button.
widthnumber3remSets the width of the button
heightnumber3remSets the height of the button
bottomnumber45Sets how many px the button should go up from the bottom
rightnumber45Sets how many px the button should go from the right to the left
leftnumbernullSets how many px the button should go from the left to the right
backgroundColorstring'#363636'Sets the background color
colorstring'#fff'Sets the color of the icon or text inside
borderRadiusnumber100Sets the roundness of the border
styleObjectnullTakes the css properties you have created
classNamestringnullTakes the class you have specified. Maybe you want to get a more pleasant appearance, for example to give the hover feature