1.0.4 • Published 3 years ago

react-simply-tabs v1.0.4

Weekly downloads
16
License
MIT
Repository
github
Last release
3 years ago

react-simply-tabs

npm version npm bundle size GitHub license

Simple and small react.js tabs component

Table of contents

Installation

npm

npm install react-simply-tabs --save

yarn

yarn add react-simply-tabs

Usage

Basic Example:

import React, { useState } from 'react';
import Tabs from 'react-simply-tabs';

const App = () => {
  const [activeTabIndex, setActiveTabIndex] = useState(0);

  return(
    <Tabs
      activeTabIndex={activeTabIndex}
      onRequestChange={setActiveTabIndex}
      controls={[
        <button type="button">
          Show 1
        </button>,
        <button type="button">
          Show 2
        </button>,
        <button type="button">
          Show 3
        </button>,
      ]}
    >
      <div>1 tab</div>

      <div>2 tab</div>

      <div>3 tab</div>
    </Tabs>
  );
};

Props

NameTypeDefault ValueDescription
activeControlPropsobject{}Props (valid DOM props or your custom props) for active control node. Will be merged with default control props
activeTabIndexnumber0Index of visible tab
activeTabPropsobject{}Props (valid DOM props or your custom props) for active tab node. Will be merged with default tab props
childrennodenullTabs nodes
controlsarray of nodes[]Array of controls nodes
controlsWrapperPropsobject{}DOM props for div inside which will be rendered controls
hiddenTabPropsobject{}Props (valid DOM props or your custom props) for hidden (not active) tab node. Will be merged with default tab props
onRequestChangefunctionFunction that will be run when the activeTabIndex is requested to be changed (either by clicking on control) (required)
renderOnlyActiveTabbooleanfalseIf true hidden tabs will not be rendered
tabsWrapperPropsobject{}DOM props for div inside which will be rendered tabs
wrapperPropsobject{}DOM props for div inside which will be rendered tabs && controls

Demo

Edit react-simply-tabs

1.0.4

3 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.1

5 years ago