npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-scroll-into-view

v2.3.0

Published

Simple React element that when clicked scrolls to any element on page

Readme

react-scroll-into-view

CI npm version downloads

A small React component that scrolls to a target element using Element.scrollIntoView() — in a fast, declarative way.

  • Declarative wrapper around element.scrollIntoView
  • Works with any clickable child (button, link, custom component)
  • Supports smooth scrolling and native scrollIntoView options

Demo

Try the CodeSandbox example:
https://codesandbox.io/s/14lxm6jmm7


Installation

Pick your package manager:

# npm
npm install react-scroll-into-view

# yarn
yarn add react-scroll-into-view

# pnpm
pnpm add react-scroll-into-view

# bun
bun add react-scroll-into-view

Quick start

1) Import

import ScrollIntoView from 'react-scroll-into-view'

2) Use it

<ScrollIntoView selector="#footer">
  <button>
    Jump to bottom
  </button>
</ScrollIntoView>

{/* somewhere down the page */}
<div id="footer">Scroll target element</div>

How it works

ScrollIntoView renders a wrapper element that listens for clicks. When clicked, it finds the element matching selector and calls scrollIntoView() with the provided options.

If you need more control, pass scrollOptions (recommended) rather than relying on legacy booleans.


Props

| Name | Type | Default | Description | | --- | --- | --- | --- | | children | React.ReactNode | | Content rendered inside the component. | | selector | string | | Required. A valid CSS selector pointing to the target element to scroll to. | | smooth | boolean | true | When true, uses smooth scrolling (equivalent to scrollOptions.behavior = 'smooth'). | | style | React.CSSProperties | | Styles applied to the wrapper element. Note: prior to v1.4.0, the default was { display: 'inline' }. | | alignToTop | boolean | false | When true, aligns the top of the target to the top of the visible area. When false, aligns to the bottom. (Maps to scrollIntoView “block” alignment behavior.) | | className | string | | Class name applied to the wrapper element. | | onClick | (event: React.MouseEvent<HTMLElement>) => void | | Optional click callback (called in addition to scrolling). | | scrollOptions | ScrollIntoViewOptions | {} | Passed to element.scrollIntoView(options). See MDN: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView#parameters. Common fields: behavior (auto/smooth), block (start/center/end/nearest), inline (start/center/end/nearest). Only valid properties are used. |


Examples

Scroll with explicit options (recommended)

<ScrollIntoView selector="#footer">
  <button >
    Jump to bottom
  </button>
</ScrollIntoView>

<!-- somewhere down on our page we have our target element -->
<div id="footer">Scroll target element</div>

Disable smooth scrolling

<!-- NOTE selector "body" targets the entire page and scrolls to the top of the screen -->
<ScrollIntoView selector="body" smooth={false}>
  <button>Back to top</button>
</ScrollIntoView>

Changelog

See GitHub releases:
https://github.com/dominikbulaj/react-scroll-into-view/releases