React component for anchor links using the smoothscroll polyfill.

Downloads in past


242201.0.125 years ago7 years agoMinified + gzip package size for react-anchor-link-smooth-scroll in KB


React Anchor Link Smooth Scroll
React component for anchor links using the smoothscroll polyfill.


  1. Install dependency: npm install react-anchor-link-smooth-scroll

  1. Add script
import React from 'react'
import ReactDOM from 'react-dom'
import AnchorLink from 'react-anchor-link-smooth-scroll'

const SmoothScroll = () => (
    <AnchorLink href='#things'>Things</AnchorLink>
    <AnchorLink href='#stuff'>Stuff</AnchorLink>

    <section id='things'>
    <section id='stuff'>

  <SmoothScroll />,
  1. Options; offset the amount of pixels from the top, for if you have a sticky navigation.
* Regular offset

   <AnchorLink offset='100' href='#things'>Things</AnchorLink>

* For responsive offset you can provide a function returning the needed integer to scroll from

   <AnchorLink offset={() => 100} href='#things'>Things</AnchorLink>


v.1.0.12 (February 5th 2019) @vai0 Modifies how the distance from the top of the page to the anchor element is calculated.
v.1.0.11 (July 24th 2018), @ericmasiello Fixed; offset prop from being spread, to avoid remaining props spread to anchor link element.
v1.0.10 (May 30th 2018), @DanMMX Created an option to receive a function for an offset calculation.
v1.0.9 (April 24th 2018), @gazpachu Fix to have hash change in address bar.
v1.0.7 (April 10th 2018), @zauni Fixed problem with nested HTML inside the anchor.
@roborourke Fixed possibility of a custom onClick handler for secondary side effects.


Licensed under the MIT Licence.