rc-tabs
tabs ui component for react
Last updated 4 months ago by zombiej .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install rc-tabs 
SYNC missed versions from official npm registry.

rc-tabs


React Tabs component.

NPM version dumi build status Test coverage 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 from 'rc-tabs';
import ReactDom from 'react-dom';

const callback = (key) => {
  console.log(key);
};

const items = [
  {
    key: '1',
    label: 'Google',
    children: (
      <div className="text-xl">
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting</p>
      </div>
    ),
  },
  {
    key: '2',
    label: <p>Amazon</p>,
    children:
      'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...',
    disabled: true,
  },
  {
    key: '3',
    label: <p>Twitter</p>,
    children: (
      <div>
        "There is no one who loves pain itself, who seeks after it and wants to have it, simply
        because it is pain..."
      </div>
    ),
  },
];

ReactDom.render(
  <Tabs
    tabPosition="bottom"
    items={items}
    defaultActiveKey="1"
    className="md:w-[70%] w-full mx-auto p-2 border-0"
    onChange={callback}
    style={{ color: 'yellow' }}
  />,
  root,
);

API

Tabs

name type default description
prefixCls string 'rc-tabs' prefix class name, use to custom style
className string - to define a class name for an element
style CSS properties - object with css properties for styling
items TabItem[] [] configure tab content
id string - unique identifier
defaultActiveKey string - initial active tabPanel's key if activeKey is absent
activeKey string - current active tabPanel's key
direction 'ltr' or 'rtl' 'ltr' Layout direction of tabs component
animated boolean | { inkBar: boolean, tabPane: boolean } { inkBar: true, tabPane: false } config animation
renderTabBar (props, TabBarComponent) => ReactElement - How to render tab bar
tabBarExtraContent ReactNode | { left: ReactNode, right: ReactNode } - config extra content
tabBarGutter number 0 config tab bar gutter
tabBarPosition 'left' \| 'right' \| 'top' \| 'bottom' 'top' tab nav 's position
tabBarStyle style - tab nav style
tabPosition 'left' or 'right' or 'top' or 'bottom' 'top' tab nav 's position
destroyInactiveTabPane boolean false whether destroy inactive TabPane when change tab
onChange (key) => void - called when tabPanel is changed
onTabClick (key) => void - called when tab click
onTabScroll ({ direction }) => void - called when tab scroll
editable { onEdit(type: 'add' | 'remove', info: { key, event }), showAdd: boolean, removeIcon: ReactNode, addIcon: ReactNode } - config tab editable
locale { dropdownAriaLabel: string, removeAriaLabel: string, addAriaLabel: string } - Accessibility locale help text
moreIcon ReactNode - collapse icon

TabItem

name type default description
key string - corresponding to activeKey, should be unique
label string - TabPane's head display text
tab ReactNode - current tab's title corresponding to current tabPane
className string - to define a class name for an element
style CSS properties - object with css properties for styling
disabled boolean false set TabPane disabled
children ReactNode - TabPane's head display content
forceRender boolean false forced render of content in tabs, not lazy render after clicking on tabs
closable boolean false closable feature of tab item
closeIcon ReactNode - Config close icon
prefixCls string 'rc-tabs-tab' prefix class name, use to custom style
id string - unique identifier
animated boolean | { inkBar: boolean, tabPane: boolean } { inkBar: true, tabPane: false } config animation
destroyInactiveTabPane boolean false whether destroy inactive TabPane when change tab
active boolean false active feature of tab item
tabKey string - key linked to tab

TabPane(support in older versions)

name type default description
destroyInactiveTabPane boolean false whether destroy inactive TabPane when change tab
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.

FAQ

Responsive Tabs

There are 3 cases when handling responsive tabs: image

We get hidden tabs through useVisibleRange.ts. If enconter the third case, in order to make tabs responsive, some tabs should be hidden. So we minus addSize when calculating basicSize manully, even though there's no addNode in container. In this way, case 3 turns to case 2, tabs become stable again.

Current Tags

  • 10.0.0-alpha.1                                ...           beta (5 years ago)
  • 15.4.0                                ...           latest (2 months ago)

228 Versions

  • 15.4.0                                ...           2 months ago
  • 15.3.0                                ...           3 months ago
  • 15.2.0                                ...           4 months ago
  • 15.1.1                                ...           6 months ago
  • 15.1.0                                ...           7 months ago
  • 15.0.0                                ...           9 months ago
  • 14.1.1                                ...           10 months ago
  • 14.1.0                                ...           10 months ago
  • 14.0.0                                ...           a year ago
  • 13.0.0                                ...           a year ago
  • 12.15.0                                ...           a year ago
  • 12.14.1                                ...           a year ago
  • 12.14.0                                ...           a year ago
  • 12.13.1                                ...           a year ago
  • 12.13.0                                ...           a year ago
  • 12.12.1                                ...           a year ago
  • 12.12.0                                ...           a year ago
  • 12.11.1                                ...           a year ago
  • 12.11.0                                ...           a year ago
  • 12.10.0                                ...           a year ago
  • 12.9.0                                ...           2 years ago
  • 12.8.1                                ...           2 years ago
  • 12.8.0                                ...           2 years ago
  • 12.7.1                                ...           2 years ago
  • 12.7.0                                ...           2 years ago
  • 12.6.0                                ...           2 years ago
  • 12.5.10                                ...           2 years ago
  • 12.5.9                                ...           2 years ago
  • 12.5.8                                ...           2 years ago
  • 12.5.7                                ...           2 years ago
  • 12.5.6                                ...           2 years ago
  • 12.5.5                                ...           2 years ago
  • 12.5.3                                ...           2 years ago
  • 12.5.1                                ...           2 years ago
  • 12.5.0                                ...           2 years ago
  • 12.4.2                                ...           2 years ago
  • 12.4.1                                ...           2 years ago
  • 12.3.0                                ...           2 years ago
  • 12.2.2                                ...           2 years ago
  • 12.2.1                                ...           2 years ago
  • 12.1.0-alpha.1                                ...           2 years ago
  • 12.1.0-alpha.0                                ...           2 years ago
  • 12.0.0-alpha.1                                ...           2 years ago
  • 12.0.0-alpha.0                                ...           2 years ago
  • 11.16.1                                ...           2 years ago
  • 11.16.0                                ...           3 years ago
  • 11.15.0                                ...           3 years ago
  • 11.14.2                                ...           3 years ago
  • 11.14.1                                ...           3 years ago
  • 11.14.0                                ...           3 years ago
  • 11.13.0                                ...           3 years ago
  • 11.12.0                                ...           3 years ago
  • 11.11.1                                ...           3 years ago
  • 11.11.0                                ...           3 years ago
  • 11.10.8                                ...           3 years ago
  • 11.10.7                                ...           3 years ago
  • 11.10.5                                ...           3 years ago
  • 11.10.4                                ...           3 years ago
  • 11.10.3                                ...           3 years ago
  • 11.10.2                                ...           3 years ago
  • 11.10.1                                ...           3 years ago
  • 11.10.0                                ...           3 years ago
  • 11.9.1                                ...           4 years ago
  • 11.9.0                                ...           4 years ago
  • 11.8.0                                ...           4 years ago
  • 11.7.3                                ...           4 years ago
  • 11.7.2                                ...           4 years ago
  • 11.7.1                                ...           4 years ago
  • 11.7.0                                ...           4 years ago
  • 11.6.2                                ...           4 years ago
  • 11.6.1                                ...           4 years ago
  • 11.5.7                                ...           4 years ago
  • 11.6.0                                ...           4 years ago
  • 11.5.6                                ...           4 years ago
  • 11.5.5                                ...           4 years ago
  • 11.5.4                                ...           4 years ago
  • 11.5.3                                ...           4 years ago
  • 11.5.2                                ...           4 years ago
  • 11.5.1                                ...           4 years ago
  • 11.5.0                                ...           5 years ago
  • 11.4.1                                ...           5 years ago
  • 11.4.0                                ...           5 years ago
  • 11.3.2                                ...           5 years ago
  • 11.3.1                                ...           5 years ago
  • 11.3.0                                ...           5 years ago
  • 11.2.4                                ...           5 years ago
  • 11.2.3                                ...           5 years ago
  • 11.2.2                                ...           5 years ago
  • 11.2.1                                ...           5 years ago
  • 11.2.0                                ...           5 years ago
  • 11.1.1                                ...           5 years ago
  • 11.1.0                                ...           5 years ago
  • 11.0.4                                ...           5 years ago
  • 11.0.3                                ...           5 years ago
  • 11.0.2                                ...           5 years ago
  • 11.0.1                                ...           5 years ago
  • 11.0.0                                ...           5 years ago
  • 10.1.1                                ...           5 years ago
  • 10.1.0                                ...           5 years ago
  • 10.0.0                                ...           5 years ago
  • 10.0.0-alpha.1                                ...           5 years ago
  • 10.0.0-alpha.0                                ...           5 years ago
  • 9.7.0                                ...           5 years ago
  • 9.6.7                                ...           5 years ago
  • 9.6.6                                ...           5 years ago
  • 9.6.5                                ...           5 years ago
  • 9.6.4                                ...           6 years ago
  • 9.6.3                                ...           6 years ago
  • 9.6.2                                ...           6 years ago
  • 9.6.1                                ...           6 years ago
  • 9.6.0                                ...           6 years ago
  • 9.5.8                                ...           6 years ago
  • 9.5.7                                ...           6 years ago
  • 9.5.6                                ...           6 years ago
  • 9.5.5                                ...           6 years ago
  • 9.5.4                                ...           6 years ago
  • 9.5.3                                ...           6 years ago
  • 9.5.2                                ...           6 years ago
  • 9.5.1                                ...           6 years ago
  • 9.5.0                                ...           6 years ago
  • 9.4.9                                ...           6 years ago
  • 9.4.8                                ...           6 years ago
  • 9.4.7                                ...           6 years ago
  • 9.4.6                                ...           6 years ago
  • 9.4.5                                ...           6 years ago
  • 9.4.4                                ...           6 years ago
  • 9.4.3                                ...           6 years ago
  • 9.4.2                                ...           6 years ago
  • 9.4.1                                ...           6 years ago
  • 9.4.0                                ...           6 years ago
  • 9.3.6                                ...           6 years ago
  • 9.3.5                                ...           6 years ago
  • 9.3.4                                ...           6 years ago
  • 9.3.3                                ...           6 years ago
  • 9.3.2                                ...           6 years ago
  • 9.3.1                                ...           6 years ago
  • 9.3.0                                ...           6 years ago
  • 9.2.6                                ...           6 years ago
  • 9.2.5                                ...           7 years ago
  • 9.2.4                                ...           7 years ago
  • 9.2.3                                ...           7 years ago
  • 9.2.2                                ...           7 years ago
  • 9.2.1                                ...           7 years ago
  • 9.2.0                                ...           7 years ago
  • 9.1.11                                ...           7 years ago
  • 9.1.10                                ...           7 years ago
  • 9.1.4                                ...           7 years ago
  • 9.1.3                                ...           7 years ago
  • 9.0.4                                ...           7 years ago
  • 9.1.2                                ...           7 years ago
  • 9.1.1                                ...           7 years ago
  • 9.1.0                                ...           7 years ago
  • 9.0.3                                ...           7 years ago
  • 9.0.2                                ...           7 years ago
  • 9.0.1                                ...           7 years ago
  • 9.0.0                                ...           7 years ago
  • 8.1.1                                ...           7 years ago
  • 8.1.0                                ...           7 years ago
  • 8.0.2                                ...           7 years ago
  • 8.0.1                                ...           7 years ago
  • 8.0.0                                ...           8 years ago
  • 8.0.0-beta.0                                ...           8 years ago
  • 7.5.0                                ...           8 years ago
  • 7.3.4                                ...           8 years ago
  • 7.3.1                                ...           8 years ago
  • 7.3.0                                ...           8 years ago
  • 7.2.0                                ...           8 years ago
  • 7.1.1                                ...           8 years ago
  • 7.1.0                                ...           8 years ago
  • 7.0.13                                ...           8 years ago
  • 7.0.12                                ...           8 years ago
  • 7.0.11                                ...           8 years ago
  • 7.0.10                                ...           8 years ago
  • 7.0.9                                ...           8 years ago
  • 7.0.8                                ...           8 years ago
  • 7.0.7                                ...           8 years ago
  • 7.0.6                                ...           8 years ago
  • 7.0.5                                ...           8 years ago
  • 7.0.4                                ...           8 years ago
  • 7.0.3                                ...           8 years ago
  • 7.0.2                                ...           8 years ago
  • 7.0.1                                ...           8 years ago
  • 7.0.0                                ...           8 years ago
  • 6.0.2                                ...           8 years ago
  • 6.0.1                                ...           8 years ago
  • 6.0.0                                ...           8 years ago
  • 5.9.3                                ...           8 years ago
  • 5.9.2                                ...           9 years ago
  • 5.9.1                                ...           9 years ago
  • 5.9.0                                ...           9 years ago
  • 5.8.3                                ...           9 years ago
  • 5.8.2                                ...           9 years ago
  • 5.8.1                                ...           9 years ago
  • 5.8.0                                ...           9 years ago
  • 5.7.1                                ...           9 years ago
  • 5.7.0                                ...           9 years ago
  • 5.6.0                                ...           9 years ago
  • 5.5.2                                ...           9 years ago
  • 5.5.1                                ...           9 years ago
  • 5.5.0                                ...           9 years ago
  • 5.4.4                                ...           9 years ago
  • 5.4.3                                ...           9 years ago
  • 5.4.2                                ...           9 years ago
  • 5.4.1                                ...           9 years ago
  • 5.4.0                                ...           9 years ago
  • 5.3.3                                ...           9 years ago
  • 5.3.2                                ...           9 years ago
  • 5.3.1                                ...           9 years ago
  • 5.3.0                                ...           9 years ago
  • 5.2.0                                ...           9 years ago
  • 5.1.0                                ...           10 years ago
  • 5.0.5                                ...           10 years ago
  • 5.0.4                                ...           10 years ago
  • 5.0.3                                ...           10 years ago
  • 5.0.2                                ...           10 years ago
  • 5.0.1                                ...           10 years ago
  • 5.0.0                                ...           10 years ago
  • 4.0.0                                ...           10 years ago
  • 3.3.0                                ...           10 years ago
  • 3.2.0                                ...           10 years ago
  • 3.1.0                                ...           10 years ago
  • 3.0.0                                ...           10 years ago
  • 2.0.4                                ...           10 years ago
  • 2.0.3                                ...           10 years ago
  • 2.0.2                                ...           10 years ago
  • 2.0.1                                ...           10 years ago
  • 2.0.0                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Downloads
Total 4
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (33)

© 2010 - cnpmjs.org x YWFE | Home | YWFE