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-tab-ui

v1.0.5

Published

A simple tab ui component for react. It is built on top of Headless UI and it is completely customizable. By default it comes with no styles, so you can customize it to your needs.

Downloads

30

Readme

React Tab Ui

A simple tab ui component for react. It is built on top of Headless UI and it is completely customizable. By default it comes with no styles, so you can customize it to your needs.

Installation

npm install react-tab-ui

Import

import { ReactTab } from "react-tab-ui";

Usage

The component takes two props, tabHead and tabData. tabHead is an array of strings and tabData is an array of react components. The length of both arrays should be the same.

<ReactTab
  tabHead={["Tab 1", "Tab 2", "Tab 3"]}
  tabData={["Tab 1 Content", "Tab 2 Content", "Tab 3 Content"]}
/>

Props

| Prop Name | Type | Description | | ----------- | ------- | ------------------------------------------------------------------------------------ | | tabHead | array | An array of strings. The length of the array should be the same as tabData. | | tabData | array | An array of react components. The length of the array should be the same as tabHead. | | rememberTab | boolean | If true, the tab will remember the last active tab. Default is false. | | selectedTab | number | The index of the tab that should be selected. Default is 0. | | insertHTML | boolean | If true, the tabData will be rendered as HTML. Default is false. |

More Examples

Render Components

import Tab1 from "./Tab1";
import Tab2 from "./Tab2";
import Tab3 from "./Tab3";

<ReactTab
  tabHead={["Tab 1", "Tab 2", "Tab 3"]}
  tabData={[<Tab1 />, <Tab2 />, <Tab3 />]}
/>;

Remember Last Active Tab

<ReactTab
  tabHead={["Tab 1", "Tab 2", "Tab 3"]}
  tabData={["Tab 1 Content", "Tab 2 Content", "Tab 3 Content"]}
  rememberTab={true}
/>

// The tab will remember the last active tab

Set Default Active Tab

<ReactTab
  tabHead={["Tab 1", "Tab 2", "Tab 3"]}
  tabData={["Tab 1 Content", "Tab 2 Content", "Tab 3 Content"]}
  selectedTab={2}
/>

// The third tab will be selected by default

Render HTML

<ReactTab
  tabHead={["Tab 1", "Tab 2", "Tab 3"]}
  tabData={[
    "<h1>Tab 1 Content</h1>",
    "<h1>Tab 2 Content</h1>",
    "<h1>Tab 3 Content</h1>",
  ]}
  insertHTML={true}
/>

// The tabData will be rendered as HTML

Styling

This is the default styling of the component. You can customize it to your needs.

:root {
  --dark-bg-zinc-900: #18181b; /* Dark mode background color */
  --dark-border-zinc-700: #31313a; /* Dark mode border color */
  --dark-text-zinc-200: #ccc; /* Dark mode text color */
}

/* .tabList */
.tabList {
  padding: 0.75rem;
  display: flex;
  gap: 0.25rem;
  background-color: #f3f4f6;
  border-radius: 8px;
  overflow-x: auto;
}

/* .tabListButton */
.tabListButton {
  font-weight: normal;
  white-space: nowrap;
  outline: none;
  transition: all 300ms ease-in-out;
  cursor: pointer;
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 0.3125rem;
  line-height: 1.25rem;
}

/* .tabListButtonSelected */
.tabListButtonSelected {
  background-color: #aee4fd;
  color: #0b74dd;
}

/* .tabListButtonUnSelected */
.tabListButtonUnSelected {
  color: black;
}

/* .tabPanelContainer */
.tabPanelContainer {
  margin-top: 0.5rem;
  height: auto;
  width: 100%;
  overflow: auto;
}

/* .tabPanel */
.tabPanel {
  padding: 0.75rem;
  background: #f3f4f6;
  border-radius: 8px;
}