Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@dimorphic/rc-tabs

react-component92MIT11.7.4TypeScript support: included

tabs ui component for react

react, react-component, react-tabs

readme

rc-tabs


React Tabs component.

NPM version build status Test coverage Dependencies DevDependencies npm download bundle size

Screenshot

Example

http://localhost:8000/examples

online example: https://tabs.react-component.now.sh/

install

rc-tabs

Feature

Keyboard

  • left and up: tabs to previous tab
  • right and down: tabs to next tab

Usage

import Tabs, { TabPane } from 'rc-tabs';

var callback = function(key) {};

React.render(
  <Tabs defaultActiveKey="2" onChange={callback}>
    <TabPane tab="tab 1" key="1">
      first
    </TabPane>
    <TabPane tab="tab 2" key="2">
      second
    </TabPane>
    <TabPane tab="tab 3" key="3">
      third
    </TabPane>
  </Tabs>,
  document.getElementById('t2'),
);

API

Tabs

name type default description
activeKey string - current active tabPanel's key
animated boolean | { inkBar: boolean, tabPane: boolean } { inkBar: true, tabPane: false } config animation
defaultActiveKey string - initial active tabPanel's key if activeKey is absent
destroyInactiveTabPane boolean false whether destroy inactive TabPane when change tab
direction `'ltr' 'rlt'` 'ltr'
editable { onEdit(type: 'add' 'remove', info: { key, event }), showAdd: boolean, removeIcon: ReactNode, addIcon: ReactNode } -
locale { dropdownAriaLabel: string, removeAriaLabel: string, addAriaLabel: string } - Accessibility locale help text
moreIcon ReactNode - collapse icon
morePopupContainer (menuDOMNode) => HTMLElement () => document.body DOM node container for 'more' dropdown popup
tabBarGutter number 0 config tab bar gutter
tabBarPosition `'left' 'right' 'top'
tabBarStyle style - tab nav style
tabBarExtraContent ReactNode | { left: ReactNode, right: ReactNode } - config extra content
renderTabBar (props, TabBarComponent) => ReactElement - How to render tab bar
prefixCls string 'rc-tabs' prefix class name, use to custom style
onChange (key) => void - called when tabPanel is changed
onTabClick (key) => void - called when tab click
onTabScroll ({ direction }) => void - called when tab scroll

TabPane

name type default description
key string - corresponding to activeKey, should be unique
forceRender boolean false forced render of content in tabs, not lazy render after clicking on tabs
tab ReactNode - current tab's title corresponding to current tabPane
closeIcon ReactNode - Config close icon

Development

npm install
npm start

Test Case

npm test
npm run chrome-test

Coverage

npm run coverage

open coverage/ dir

License

rc-tabs is released under the MIT license.

changelog

History


https://github.com/react-component/tabs/releases

10.1.0 / 2020-03-17

  • Add keyboard prop.
  • extraContent don't trigger keyboard navigate now.
  • Remove prop-types and clean up dependencies.

9.6.0 / 2019-01-16

  • ScrollableInkTabBar support render props to customize TabNode

9.4.0 / 2018-08-13

  • Add prevIcon and nextIcon.

9.3.0 / 2018-06-12

  • Add MouseEvent as second parameter to onTabClick.

9.2.0 / 2018-01-01

  • Add tabBarGutter.
  • Fix #84

9.1.2 / 2017-08-15

  • Fix responsive.
  • Improve scroll to active animation.

9.1.0 / 2017-08-13

  • Support add data-* to Tabs dom.

9.0.0 / 2017-08-04

  • Refactor extraContent dom structure.

7.1.0 / 2016-12-06

  • support animatedWithMargin

7.0.0 / 2016-08-29

  • modularize tabBar and tabContent

6.0.0 / 2016-08-20

  • support allowInkBar/allowScrollBar prop

5.9.0 / 2016-04-26

  • use transform instead of left/top

5.5.0 / 2015-11-11

  • add destroyInactiveTabPane prop to destroy inactive tab pane when change tab

5.4.0 / 2015-10-20

  • support add/tabBarExtraContent
  • only support react 0.14+
  • remove bootstrap css

5.3.0 / 2015-07-23

use rc-animate

5.2.0 / 2015-07-06

support tabPosition

5.1.0 / 2015-06-10

change effect props to animation

5.0.0 / 2015-04-30

new #3 support slide effect

3.3.0 / 2015-04-30

improved #6 support defaultActiveFirst

3.2.0 / 2015-04-20

improved #4 lazy render on initial render and update