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

scrolling-tabs

v0.8.7

Published

[Interactive Demo & Docs](https://tabs.js.org)

Downloads

235

Readme

Overview

Interactive Demo & Docs

Github Repo

This is a component for creating scrolling tabs. Objectives are:

  • Automatically scroll to a section by clicking on its respective tab button.
  • Automatically highlight a tab button when the corresponding section is scrolled into view.
  • Simple predefined styles that are easily customizable.

Installation

Peer Dependencies

As this is a React component, you must have already installed react and react-dom.

The other peer dependency can be installed via the following command:

npm install react-draggable

Detailed version requirements for all dependencies:

  • react >= 16.3.0
  • react-dom >= 16.3.0
  • react-draggable >= 4.0

Installing

After dependency installation, run the following command to install the package:

npm install scrolling-tabs

Component Structure

There are 4 components which should be structured as follows:

<ScrollingTabs>
  <Tabs>
    <Tab>First Tab</Tab>
    <Tab>Second Tab</Tab>
    ...
  </Tabs>

  <TabContext>
    First Tab context
  </TabContext>
  <TabContext>
    Second Tab context
  </TabContext>
  ...
</ScrollingTabs>

RTL

The component checks for the direction of the component, and if it is inside an RTL context (e.g., parent elements with dir='rtl'), it will render with RTL features.

You can set dir='rtl' on the document body or any parent of the <ScrollingTabs> component.

Customization

ClassName and Style

Aside from the tabColor and tabStyle props on the <ScrollingTabs> component, you can customize it by passing className and style props to <Tabs>, <Tab>, or <TabContext>.

The <Tab> component will have an active class on the selected tab. It also has two extra props: activeStyle and activeClassName, which are set only for the active tab.

Based on tabStyle and tabColor props, styles are composed in the following order:

For any Tab:

  • Default styles based on tabStyle.
  • Styles provided through style prop on the Tab component.

For the active Tab:

  • Default styles based on tabStyle.
  • Default active styles based on tabStyle.
  • Styles provided through style prop on the Tab component.
  • Styles provided through activeStyle prop on the Tab component.

Even with tabStyle set to none, the following styles are applied to avoid bad tab display:

{
  display: 'inline-block',
  padding-right: 15px,
  padding-left: 15px,
  margin-right: 5px,
  margin-left: 5px,
  transition: 'all .5s',
  cursor: 'pointer'
}

.sticked

The <Tab> component will have .sticked when it is sticked to the top of the page. You can use this class to style the tabs bar differently from when it is not sticky yet.

Responsivity

The component is responsive and will automatically scroll horizontally to the selected tab on smaller screens. If the <Tabs> component is wider than the screen, it will scroll horizontally to show all tabs.

Two arrows are displayed in the rightmost and leftmost spaces of the horizontal tabs bar. These can be removed by setting the boolean hideArrows prop to true.

Troubleshooting

If any parent element has overflow: hidden, the CSS sticky position will not work. Instead, use overflow: clip.

If you have any issue, please feel free to submit an issue at https://github.com/mehrizi/tabs/issues