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

@arterial/tabs

v3.0.0

Published

Another React Material Tabs

Downloads

39

Readme

Arterial Tabs

Another React Material Tab

Installation

npm install @arterial/tabs

Usage

Styles

Sass

@use "@material/tab-bar/index.scss" as tab-bar;
@use "@material/tab-indicator/index.scss" as tab-indicator;
@use "@material/tab-scroller/index.scss" as tab-scroller;
@use "@material/tab/index.scss" as tab;
@include tab-bar.core-styles;
@include tab-indicator.core-styles;
@include tab-scroller.core-styles;
@include tab.core-styles;

CSS

import '@material/tab-bar/dist/mdc.tab-bar.css';
import '@material/tab-indicator/dist/mdc.tab-indicator.css';
import '@material/tab-scroller/dist/mdc.tab-scroller.css';
import '@material/tab/dist/mdc.tab.css';

JSX

import {Tab, TabBar} from '@arterial/tabs';

Regular Tabs

function Regular() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="home" label="Home" />
      <Tab id="merchandise" label="Merchandise" />
      <Tab id="about-us" label="About Us" />
    </TabBar>
  );
}

Other Variants

Min Width

function MinWidth() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="home" label="Home" minWidth />
      <Tab id="merchandise" label="Merchandise" minWidth />
      <Tab id="about-us" label="About Us" minWidth />
    </TabBar>
  );
}

Icon

function Icon() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="recents" label="Recents" icon="watch_later" />
      <Tab id="nearby" label="Nearby" icon="near_me" />
      <Tab id="favorites" label="Favorites" icon="favorite" />
    </TabBar>
  );
}

Stacked

function Stacked() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="recents" label="Recents" icon="watch_later" stacked />
      <Tab id="nearby" label="Nearby" icon="near_me" stacked />
      <Tab id="favorites" label="Favorites" icon="favorite" stacked />
    </TabBar>
  );
}

Stacked and Restricted

function StackedRestricted() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="recents" label="Recents" icon="watch_later" restricted stacked />
      <Tab id="nearby" label="Nearby" icon="near_me" restricted stacked />
      <Tab
        id="favorites"
        label="Favorites"
        icon="favorite"
        restricted
        stacked
      />
    </TabBar>
  );
}

Stacked and Restricted

function StackedRestricted() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="recents" label="Recents" icon="watch_later" restricted stacked />
      <Tab id="nearby" label="Nearby" icon="near_me" restricted stacked />
      <Tab
        id="favorites"
        label="Favorites"
        icon="favorite"
        restricted
        stacked
      />
    </TabBar>
  );
}

Indicator Fade

function IndicatorFade() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="recents" label="Recents" indicatorFade />
      <Tab id="nearby" label="Nearby" indicatorFade />
      <Tab id="favorites" label="Favorites" indicatorFade />
    </TabBar>
  );
}

Indicator Icon

function IndicatorIcon() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
    >
      <Tab id="recents" label="Recents" indicatorIcon="star" />
      <Tab id="nearby" label="Nearby" indicatorIcon="star" />
      <Tab id="favorites" label="Favorites" indicatorIcon="star" />
    </TabBar>
  );
}

Scrolling

function getTabs() {
  const tabs = [];
  for (let i = 0; i < 36; i++) {
    tabs.push(`Tab ${i + 1}`);
  }
  return tabs;
}
function Scrolling() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <TabBar
      activeIndex={activeIndex}
      handleActiveIndexUpdate={index => setActiveIndex(index)}
      scroll
    >
      {getTabs().map(label => (
        <Tab id={label} key={label} label={label} />
      ))}
    </TabBar>
  );
}

Props

Tab

| Name | Type | Description | | --------------------------- | ---------------- | --------------------------------------------------------------- | | active | boolean | Indicates whether the element is active. | | children | node | Elements to be displayed within root element. | | className | string | Classes to be applied to the root element. | | focused | boolean | Indicates whether the element is focused. | | id | string | Id of the element. | | indicatorFade | boolean | Enables indicator element fade animation. | | indicatorIcon | boolean | Icon to render within as indicator element. | | indicatorId | boolean | ID of indicator element. | | label | string | Text to be displayed within the root element. | | minWidth | boolean | Enables a min width variant. | | previousIndicatorClientRect | object | Conains previous indicator element's client rect. | | restricted | boolean | Enables a restricted variant. | | ripple | boolean | Enables ripple within root element. Defaults to true. | | stacked | boolean | Enables a stacked variant. | | tag | string | object | HTML tag to be applied to the root element. Defaults to button. |

TabBar

| Name | Type | Description | | ----------------------- | ---------------- | --------------------------------------------------------------------- | | activeIndex | boolean | Indicates the tab at that index is active. | | children | node | Elements to be displayed within root element. | | className | string | Classes to be applied to the root element. | | dir | ltr | rtl | Indicates the directionality of the element's text. Defaults to auto. | | handleActiveIndexUpdate | function | Active index update event handler. | | onKeyDown | function | Keydown event handler. | | tag | string | object | HTML tag to be applied to the root element. Defaults to div. |