react-icons/io#IoIosArrowDropupCircle JavaScript Examples

The following examples show how to use react-icons/io#IoIosArrowDropupCircle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Layout.jsx    From nextjs-prismic-blog-starter with MIT License 6 votes vote down vote up
Layout = ({title, pathUrl, page, description, image, children}) => {
  const URL = siteUrl(pathUrl || routeURL())
  const siteImage = image || siteUrl('/site_image.png')
  return (
    <>
      <Head
        pathUrl={URL}
        page={page}
        title={title}
        description={description}
        image={siteImage}></Head>
      <div className='content-wrapper'>
        <Header />
        <main className='main'>{children}</main>
        <Footer />
        <IoIosArrowDropupCircle
          className='scroll-top-icon'
          onClick={() => {
            scrollTo({
              top: 0,
              left: 0,
              behavior: 'smooth',
            })
          }}
        />
      </div>
    </>
  )
}
Example #2
Source File: BackToTop.js    From developer-portfolio with Apache License 2.0 5 votes vote down vote up
function BackToTop() {
    const [visible, setVisible] = useState(false);

    const { theme } = useContext(ThemeContext);

    const toggleVisible = () => {
        const scrolled = document.documentElement.scrollTop;
        if (scrolled > 300) {
            setVisible(true);
        } else if (scrolled <= 300) {
            setVisible(false);
        }
    };

    const scrollToTop = () => {
        window.scrollTo({
            top: 0,
            behavior: 'smooth',
        });
    };

    window.addEventListener('scroll', toggleVisible);

    const useStyles = makeStyles(() => ({
        icon: {
            fontSize: '3rem',
            color: theme.tertiary,
        },
    }));

    const classes = useStyles();

    return (
        <div
            style={{ display: visible ? 'inline' : 'none' }}
            className='backToTop'
        >
            <button onClick={scrollToTop} aria-label='Back to top'>
                <IoIosArrowDropupCircle className={classes.icon} />
            </button>
        </div>
    );
}