🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

The plugin is inspired by Atom and allows you to use these beautiful tabs in your React App.

Others React

Documentation

React draggable tabs npm version

The plugin is inspired by Atom and allows you to use these beautiful tabs in your React App screenshot of the tabs

Install

just download the repo from npm

npm install react-draggable-tabs --save

Usage

You can import the Tabs component

import Tabs from "react-draggable-tabs"  ...  <Tabs />

The Tabs component requires 4 props:

  • tabs: an array of tabs, ever tab is an object and has to contain an id and a content (string or React element), e.g. tabs = [{id:1, content: "Tab 1"}, {id:2, content: "Tab 2"}]
  • moveTab(dragIndex, hoverIndex): a function handling the drag action, it receives the index in the array of the dragged item and of the landing place
  • selectTab(selectedIndex): handles the click event, it receives the index of the clicked tab
  • closeTab(selectedIndex): handles the remove event, it receives the index of the closed tab

You can also add children to the Tabs and they will be placed in the right-most position, it's useful if you want to add control buttons, for example to open a new tab.

<Tabs {/* ...*/}> <button>+</button> </Tabs>

Example

Checkout the live example here
Edit n0952xxo6p


You May Also Like