Socket
Socket
Sign inDemoInstall

react-scroll-to-element

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll-to-element

Scroll to any element of your React application


Version published
Weekly downloads
418
increased by72.02%
Maintainers
1
Weekly downloads
 
Created
Source

react-scroll-to-element

Scroll to any element of your React application

Build Status Dependencies devDependencies

Getting Started

1. Install

npm install react-scroll-to-element or yarn add react-scroll-to-element

2. Options

OptionValueDescription
typestringid or class - Not required if you want to set offset only
elementstringScroll to this element (use with type)
offsetnumberScroll x pixels down
timeoutnumberStart scrolling after x ms
childrenstringText or html tags

3. Usage


import Scroll from 'react-scroll-to-element';

<Scroll type="id" element="title">
  Scroll to element with id 'title'
</Scroll>

<Scroll type="class" element="contact">
  Scroll to element with class 'contact'
</Scroll>

<Scroll>
  Scroll to top
</Scroll>

<Scroll offset={200}>
  Scroll 200 px down (from top)
</Scroll>

<Scroll offset={200} timeout={3000}>
  Scroll 200 px down (from top) after 3 seconds
</Scroll>

<Scroll type="class" element="contact" offset={200} timeout={3000}>
  Scroll to element with class 'contact' + 200 px down after 3 seconds
</Scroll>

<Scroll type="class" element="contact" offset={-100}>
  Scroll to element with class 'contact' - 100 px
</Scroll>

You can also use html tags inside the component

<Scroll type="class" element="contact" offset={-100} timeout={3000}>
  <button>Click me</button>
</Scroll>

smoothscroll-polyfill used for older browsers

License

MIT

Keywords

FAQs

Package last updated on 26 Nov 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc