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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-sections-scroller

v1.0.2

Published

Simple React library for smooth scrolling to sections

Downloads

3

Readme

react-sections-scroller

A simple & Fast & lightweight React library works on .js and .ts files, build with TypeScript for creating a smooth scrolling experience to sections on the same webpage from a navigation bar. (keep it simple)

Installation

$yarn add react-sections-scroller

or

$npm install react-sections-scroller

Importing

import { Section, SectionLink } from 'react-sections-scroller';

Basic usage


import { Section, SectionLink } from 'react-sections-scroller';

// The SectionLink component redirect to the Section
  <SectionLink to="about" className="">
    About
  </SectionLink>
  
// The Section component defines a scrollable section
  <Section id="about" className="">
    <h2>This is About section</h2>
  </Section>
  
 // that's why both props are required... "to" and "id"
 // className is optional but recommended! 

🛑🔥 Styling SectionLink auto generate:

so link will change into color:🟥red by default without any style in your project, can be changed using

  1. activeColor

  2. inactiveColor

    <SectionLink to="section1" activeColor='active' inactiveColor='inactive'>Section 1</SectionLink>

then in your style.css create:

    .active{
        color:blue;
    }
    // also optional
    .inactive{
        color:black;
    }

🛑🔥 TailWind Styling also available SectionLink can be change easly using activeColor, inactiveColor

    <SectionLink to="section1" activeColor='text-black' inactiveColor='text-white'>Section 1</SectionLink>

Best Practice

Full Example of only 2 steps

1- create Navbar component add this code

⚠ Hint: feel free to use component js, jsx, ts,tsx

import React from 'react';
import { SectionLink } from 'react-sections-scroller';
// The SectionLink component redirect to the Section
export default function Nav() {

  return (
    <nav>
    <SectionLink to="aboutSection">About</SectionLink>
    <SectionLink to="contactSection">Contact</SectionLink>
    <SectionLink to="servicesSection">Services</SectionLink>
  </nav>
  )
}

2- create AboutSection component add this code

⚠ Hint: About component suppose to be a section in the same page, it's not routing to any other page

import React from 'react'
import { Section } from 'react-sections-scroller'
/ The Section component defines a scrollable section
export default function AboutSection() {
  return (
    <div>
      <Section id="aboutSection" className="">
        <h2>I'm about section</h2>
      </Section>
      </div>
  )
}

sample of app component:

import React from "react";
import AboutSection from "./AboutSection";
import "./App.css";
import Nav from "./Nav";

function App() {
  return (
    <div>
      <Nav />
      <AboutSection />
    </div>
  );
}
export default App;

About

react-sections-scroller is a lightweight and easy-to-use React library designed to enhance user experience by enabling smooth scrolling functionality between sections on a webpage. It provides a seamless integration with navigation bars, allowing users to effortlessly navigate to different sections on the page.

With react-sections-scroller, you can easily implement a smooth scroll behavior without the need for complex configuration. Simply include the library in your project and start creating a more interactive and engaging user experience.

This library is suitable for a wide range of web applications, including personal websites, portfolios, blogs, and more. It offers a straightforward solution for adding a polished touch to your website's navigation and enhancing overall usability.

Features

✅ Smooth scrolling behavior

✅ Seamless integration with navigation bars

✅ Lightweight and easy to implement

✅ Enhances user experience and navigation

✅ Suitable for various web applications

Usage

To use react-sections-scroller in your React application, simply import the necessary components (only 2 for now) and configure the desired settings to enable smooth scrolling between sections. Here is a basic example to get you started:

For more detailed usage instructions and example configurations, please refer to the documentation.

Contribution We welcome contributions from the community to help improve and enhance react-sections-scroller.

Let's make smooth scrolling even better together!

Thank you for considering react-sections-scroller for your project. We hope it brings a smooth and enjoyable scrolling experience to your users. If you have any questions or need further assistance, please don't hesitate to reach out.

Happy scrolling! 🚀🌟

License 🔖

MIT.