15.0.0 • Published 21 days ago

rc-tabs v15.0.0

Weekly downloads
542,632
License
MIT
Repository
github
Last release
21 days ago

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

nametypedefaultdescription
prefixClsstring'rc-tabs'prefix class name, use to custom style
classNamestring-to define a class name for an element
styleCSS properties-object with css properties for styling
itemsTabItem[][]configure tab content
idstring-unique identifier
defaultActiveKeystring-initial active tabPanel's key if activeKey is absent
activeKeystring-current active tabPanel's key
direction'ltr' or 'rtl''ltr'Layout direction of tabs component
animatedboolean | { inkBar: boolean, tabPane: boolean }{ inkBar: true, tabPane: false }config animation
renderTabBar(props, TabBarComponent) => ReactElement-How to render tab bar
tabBarExtraContentReactNode | { left: ReactNode, right: ReactNode }-config extra content
tabBarGutternumber0config tab bar gutter
tabBarPosition'left' \| 'right' \| 'top' \| 'bottom''top'tab nav 's position
tabBarStylestyle-tab nav style
tabPosition'left' or 'right' or 'top' or 'bottom''top'tab nav 's position
destroyInactiveTabPanebooleanfalsewhether 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
moreIconReactNode-collapse icon

TabItem

nametypedefaultdescription
keystring-corresponding to activeKey, should be unique
labelstring-TabPane's head display text
tabReactNode-current tab's title corresponding to current tabPane
classNamestring-to define a class name for an element
styleCSS properties-object with css properties for styling
disabledbooleanfalseset TabPane disabled
childrenReactNode-TabPane's head display content
forceRenderbooleanfalseforced render of content in tabs, not lazy render after clicking on tabs
closablebooleanfalseclosable feature of tab item
closeIconReactNode-Config close icon
prefixClsstring'rc-tabs-tab'prefix class name, use to custom style
idstring-unique identifier
animatedboolean | { inkBar: boolean, tabPane: boolean }{ inkBar: true, tabPane: false }config animation
destroyInactiveTabPanebooleanfalsewhether destroy inactive TabPane when change tab
activebooleanfalseactive feature of tab item
tabKeystring-key linked to tab

TabPane(support in older versions)

nametypedefaultdescription
destroyInactiveTabPanebooleanfalsewhether destroy inactive TabPane when change tab
keystring-corresponding to activeKey, should be unique
forceRenderbooleanfalseforced render of content in tabs, not lazy render after clicking on tabs
tabReactNode-current tab's title corresponding to current tabPane
closeIconReactNode-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.

15.0.0

21 days ago

14.1.0

2 months ago

14.1.1

2 months ago

14.0.0

4 months ago

13.0.0

4 months ago

12.15.0

5 months ago

12.13.0

6 months ago

12.13.1

6 months ago

12.14.1

5 months ago

12.14.0

5 months ago

12.10.0

9 months ago

12.11.1

8 months ago

12.11.0

8 months ago

12.12.1

8 months ago

12.12.0

8 months ago

12.8.0

10 months ago

12.8.1

10 months ago

12.7.0

11 months ago

12.7.1

11 months ago

12.9.0

10 months ago

12.6.0

12 months ago

12.5.7

1 year ago

12.5.8

1 year ago

12.5.9

1 year ago

12.5.10

1 year ago

12.4.1

1 year ago

12.4.2

1 year ago

12.3.0

1 year ago

12.5.3

1 year ago

12.5.5

1 year ago

12.5.0

1 year ago

12.5.1

1 year ago

12.5.6

1 year ago

12.2.1

2 years ago

12.2.2

1 year ago

12.1.0-alpha.1

2 years ago

11.16.0

2 years ago

11.16.1

2 years ago

11.15.0

2 years ago

11.14.2

2 years ago

12.0.0-alpha.1

2 years ago

12.0.0-alpha.0

2 years ago

12.1.0-alpha.0

2 years ago

11.14.0

2 years ago

11.14.1

2 years ago

11.13.0

2 years ago

11.12.0

2 years ago

11.11.1

2 years ago

11.11.0

2 years ago

11.10.8

2 years ago

11.10.7

2 years ago

11.10.5

2 years ago

11.10.4

2 years ago

11.10.3

2 years ago

11.10.2

3 years ago

11.10.1

3 years ago

11.10.0

3 years ago

11.9.1

3 years ago

11.9.0

3 years ago

11.8.0

3 years ago

11.7.3

3 years ago

11.7.2

3 years ago

11.7.1

3 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

4 years ago

11.4.0

4 years ago

11.4.1

4 years ago

11.3.2

4 years ago

11.3.1

4 years ago

11.3.0

4 years ago

11.2.4

4 years ago

11.2.3

4 years ago

11.2.2

4 years ago

11.2.1

4 years ago

11.2.0

4 years ago

11.1.1

4 years ago

11.1.0

4 years ago

11.0.4

4 years ago

11.0.3

4 years ago

11.0.2

4 years ago

11.0.1

4 years ago

11.0.0

4 years ago

10.1.1

4 years ago

10.1.0

4 years ago

10.0.0

4 years ago

10.0.0-alpha.1

4 years ago

10.0.0-alpha.0

4 years ago

9.7.0

4 years ago

9.6.7

5 years ago

9.6.6

5 years ago

9.6.5

5 years ago

9.6.4

5 years ago

9.6.3

5 years ago

9.6.2

5 years ago

9.6.1

5 years ago

9.6.0

5 years ago

9.5.8

5 years ago

9.5.7

5 years ago

9.5.6

5 years ago

9.5.5

5 years ago

9.5.4

5 years ago

9.5.3

5 years ago

9.5.2

5 years ago

9.5.1

5 years ago

9.5.0

5 years ago

9.4.9

5 years ago

9.4.8

5 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

6 years ago

9.2.4

6 years ago

9.2.3

6 years ago

9.2.2

6 years ago

9.2.1

6 years ago

9.2.0

6 years ago

9.1.11

6 years ago

9.1.10

6 years ago

9.1.9

7 years ago

9.1.8

7 years ago

9.1.7

7 years ago

9.1.6

7 years ago

9.1.5

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

7 years ago

8.0.0-beta.0

7 years ago

7.5.0

7 years ago

7.3.4

7 years ago

7.3.3

7 years ago

7.3.1

7 years ago

7.3.0

7 years ago

7.2.0

7 years ago

7.1.1

7 years ago

7.1.0

7 years ago

7.0.13

7 years ago

7.0.12

7 years ago

7.0.11

7 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

8 years ago

5.9.1

8 years ago

5.9.0

8 years ago

5.8.3

8 years ago

5.8.2

8 years ago

5.8.1

8 years ago

5.8.0

8 years ago

5.7.1

8 years ago

5.7.0

8 years ago

5.6.0

8 years ago

5.5.2

8 years ago

5.5.1

8 years ago

5.5.0

8 years ago

5.4.4

8 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

9 years ago

5.0.5

9 years ago

5.0.4

9 years ago

5.0.3

9 years ago

5.0.2

9 years ago

5.0.1

9 years ago

5.0.0

9 years ago

4.0.0

9 years ago

3.3.0

9 years ago

3.2.0

9 years ago

3.1.0

9 years ago

3.0.0

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.0

9 years ago