Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-tabs

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-tabs

An accessible and easy tab component for ReactJS

  • 6.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is react-tabs?

The react-tabs package is a simple and flexible tab component for React applications. It allows developers to create tabbed interfaces with ease, providing a straightforward API and customizable components.

What are react-tabs's main functionalities?

Basic Tabs

This feature allows you to create a basic tabbed interface with multiple tabs and corresponding content panels.

import { Tabs, TabList, Tab, TabPanel } from 'react-tabs';
import 'react-tabs/style/react-tabs.css';

function App() {
  return (
    <Tabs>
      <TabList>
        <Tab>Tab 1</Tab>
        <Tab>Tab 2</Tab>
        <Tab>Tab 3</Tab>
      </TabList>

      <TabPanel>
        <h2>Content for Tab 1</h2>
      </TabPanel>
      <TabPanel>
        <h2>Content for Tab 2</h2>
      </TabPanel>
      <TabPanel>
        <h2>Content for Tab 3</h2>
      </TabPanel>
    </Tabs>
  );
}

Custom Styling

This feature demonstrates how to apply custom styling to the tabs by using a custom CSS file.

import { Tabs, TabList, Tab, TabPanel } from 'react-tabs';
import './custom-tabs.css';

function App() {
  return (
    <Tabs>
      <TabList>
        <Tab className="custom-tab">Tab 1</Tab>
        <Tab className="custom-tab">Tab 2</Tab>
        <Tab className="custom-tab">Tab 3</Tab>
      </TabList>

      <TabPanel>
        <h2>Content for Tab 1</h2>
      </TabPanel>
      <TabPanel>
        <h2>Content for Tab 2</h2>
      </TabPanel>
      <TabPanel>
        <h2>Content for Tab 3</h2>
      </TabPanel>
    </Tabs>
  );
}

Dynamic Tabs

This feature shows how to create dynamic tabs that can be added or removed at runtime.

import { useState } from 'react';
import { Tabs, TabList, Tab, TabPanel } from 'react-tabs';

function App() {
  const [tabs, setTabs] = useState([
    { title: 'Tab 1', content: 'Content for Tab 1' },
    { title: 'Tab 2', content: 'Content for Tab 2' }
  ]);

  const addTab = () => {
    setTabs([...tabs, { title: `Tab ${tabs.length + 1}`, content: `Content for Tab ${tabs.length + 1}` }]);
  };

  return (
    <div>
      <button onClick={addTab}>Add Tab</button>
      <Tabs>
        <TabList>
          {tabs.map((tab, index) => (
            <Tab key={index}>{tab.title}</Tab>
          ))}
        </TabList>

        {tabs.map((tab, index) => (
          <TabPanel key={index}>
            <h2>{tab.content}</h2>
          </TabPanel>
        ))}
      </Tabs>
    </div>
  );
}

Other packages similar to react-tabs

Keywords

FAQs

Package last updated on 17 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc