1.0.1 • Published 4 years ago

react-tabs-with-components v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

A useful react tabs library

npm

Using tab with component list

Installation

npm install react-tabs-with-components

Usage

import React from 'react';
import Tabs from 'react-tabs-with-components';

function Tab1() {
  return (<div>
    Tab1 Content
  </div>)
}

function Tab2() {
  return (<div>
    Tab2 Content
  </div>)
}

const tabs = [
  {
    title: 'Tab 1',
    component: <Tab1 />,
    visible: true
  },
  {
    title: 'Tab 2',
    component: <Tab2 />,
    visible: true
  }
];

function App() {
  return (
    <div className="App">
      <Tabs tabs={tabs} defaultActiveTab={0} />
    </div>
  );
}

export default App;

Props

PropTypeDefaultDescription
deafultValueint0Which step will be active at the beginning
tabsarrayRequiredComponent list of steps

Notes

  • tabs prop should look like this
{
    title: <string>,
    component: <component>,
    visible: <bool>  // If true is given, tabs are also shown. If false, the tabs are also hidden.
}
  • If the tab is closed, only the visible value is false and the tab is not destroyed.

  • "visible" value must be true to open closed tab