react-tabs-with-components

1.0.1 • Public • Published

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

Prop Type Default Description
deafultValue int 0 Which step will be active at the beginning
tabs array Required Component 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

Readme

Keywords

none

Package Sidebar

Install

npm i react-tabs-with-components

Weekly Downloads

9

Version

1.0.1

License

ISC

Unpacked Size

12.1 kB

Total Files

3

Last publish

Collaborators

  • cinkagan