@@ -41,24 +41,53 @@ online example: https://tabs.react-component.now.sh/
4141
4242## Usage
4343
44- ``` js
45- import Tabs , { TabPane } from ' rc-tabs' ;
46-
47- var callback = function (key ) {};
48-
49- React .render (
50- < Tabs defaultActiveKey= " 2" onChange= {callback}>
51- < TabPane tab= " tab 1" key= " 1" >
52- first
53- < / TabPane>
54- < TabPane tab= " tab 2" key= " 2" >
55- second
56- < / TabPane>
57- < TabPane tab= " tab 3" key= " 3" >
58- third
59- < / TabPane>
60- < / Tabs> ,
61- document .getElementById (' t2' ),
44+ ``` tsx | pure
45+ import Tabs from ' rc-tabs' ;
46+ import ReactDom from ' react-dom' ;
47+
48+ const callback = (key ) => {
49+ console .log (key );
50+ };
51+
52+ const items = [
53+ {
54+ key: ' 1' ,
55+ label: ' Google' ,
56+ children : (
57+ <div className = " text-xl" >
58+ <p >Lorem Ipsum is simply dummy text of the printing and typesetting</p >
59+ </div >
60+ ),
61+ },
62+ {
63+ key: ' 2' ,
64+ label: <p >Amazon</p >,
65+ children:
66+ ' Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...' ,
67+ disabled: true ,
68+ },
69+ {
70+ key: ' 3' ,
71+ label: <p >Twitter</p >,
72+ children : (
73+ <div >
74+ "There is no one who loves pain itself, who seeks after it and wants to have it, simply
75+ because it is pain..."
76+ </div >
77+ ),
78+ },
79+ ];
80+
81+ ReactDom .render (
82+ <Tabs
83+ tabPosition = " bottom"
84+ items = { items }
85+ defaultActiveKey = " 1"
86+ className = " md:w-[70%] w-full mx-auto p-2 border-0"
87+ onChange = { callback }
88+ style = { { color: ' yellow' }}
89+ />,
90+ root ,
6291);
6392```
6493
@@ -68,29 +97,57 @@ React.render(
6897
6998| name | type | default | description |
7099| --- | --- | --- | --- |
100+ | prefixCls | string | ` 'rc-tabs' ` | prefix class name, use to custom style |
101+ | className | string | - | to define a class name for an element |
102+ | style | CSS properties | - | object with css properties for styling |
103+ | items | TabItem[ ] | [ ] | configure tab content |
104+ | id | string | - | unique identifier |
105+ | defaultActiveKey | string | - | initial active tabPanel's key if activeKey is absent |
71106| activeKey | string | - | current active tabPanel's key |
107+ | direction | ` 'ltr' or 'rtl' ` | ` 'ltr' ` | Layout direction of tabs component |
72108| animated | boolean \| { inkBar: boolean, tabPane: boolean } | ` { inkBar: true, tabPane: false } ` | config animation |
73- | defaultActiveKey | string | - | initial active tabPanel's key if activeKey is absent |
74- | destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
75- | direction | `'ltr' | 'rlt'` | ` 'ltr' ` | Layout direction of tabs component |
76- | editable | { onEdit(type: 'add' | 'remove', info: { key, event }), showAdd: boolean, removeIcon: ReactNode, addIcon: ReactNode } | - | config tab editable |
77- | locale | { dropdownAriaLabel: string, removeAriaLabel: string, addAriaLabel: string } | - | Accessibility locale help text |
78- | moreIcon | ReactNode | - | collapse icon |
109+ | renderTabBar | (props, TabBarComponent) => ReactElement | - | How to render tab bar |
110+ | tabBarExtraContent | ReactNode \| ` { left: ReactNode, right: ReactNode } ` | - | config extra content |
79111| tabBarGutter | number | 0 | config tab bar gutter |
80- | tabBarPosition | `'left' | 'right' | 'top' | 'bottom'` | ` 'top' ` | tab nav 's position |
112+ | tabBarPosition | ` 'left' \ | 'right' \ | 'top' \ | 'bottom' ` | ` 'top' ` | tab nav 's position |
81113| tabBarStyle | style | - | tab nav style |
82- | tabBarExtraContent | ReactNode \| ` { left: ReactNode, right: ReactNode } ` | - | config extra content |
83- | renderTabBar | (props, TabBarComponent) => ReactElement | - | How to render tab bar |
84- | prefixCls | string | ` 'rc-tabs' ` | prefix class name, use to custom style |
114+ | tabPosition | ` 'left' or 'right' or 'top' or 'bottom' ` | ` 'top' ` | tab nav 's position |
115+ | destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
85116| onChange | (key) => void | - | called when tabPanel is changed |
86117| onTabClick | (key) => void | - | called when tab click |
87118| onTabScroll | ({ direction }) => void | - | called when tab scroll |
119+ | editable | { onEdit(type: 'add' \| 'remove', info: { key, event }), showAdd: boolean, removeIcon: ReactNode, addIcon: ReactNode } | - | config tab editable |
120+ | locale | { dropdownAriaLabel: string, removeAriaLabel: string, addAriaLabel: string } | - | Accessibility locale help text |
121+ | moreIcon | ReactNode | - | collapse icon |
88122
89- ### TabPane
123+ ### TabItem
90124
91125| name | type | default | description |
92126| --- | --- | --- | --- |
93127| key | string | - | corresponding to activeKey, should be unique |
128+ | label | string | - | TabPane's head display text |
129+ | tab | ReactNode | - | current tab's title corresponding to current tabPane |
130+ | className | string | - | to define a class name for an element |
131+ | style | CSS properties | - | object with css properties for styling |
132+ | disabled | boolean | false | set TabPane disabled |
133+ | children | ReactNode | - | TabPane's head display content |
134+ | forceRender | boolean | false | forced render of content in tabs, not lazy render after clicking on tabs |
135+ | closable | boolean | false | closable feature of tab item |
136+ | closeIcon | ReactNode | - | Config close icon |
137+ | prefixCls | string | ` 'rc-tabs-tab' ` | prefix class name, use to custom style |
138+ | id | string | - | unique identifier |
139+ | animated | boolean \| { inkBar: boolean, tabPane: boolean } | ` { inkBar: true, tabPane: false } ` | config animation |
140+ | destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
141+ | active | boolean | false | active feature of tab item |
142+ | tabKey | string | - | key linked to tab |
143+
144+
145+ ### TabPane(support in older versions)
146+
147+ | name | type | default | description |
148+ | --- | --- | --- | --- |
149+ | destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
150+ | key | string | - | corresponding to activeKey, should be unique |
94151| forceRender | boolean | false | forced render of content in tabs, not lazy render after clicking on tabs |
95152| tab | ReactNode | - | current tab's title corresponding to current tabPane |
96153| closeIcon | ReactNode | - | Config close icon |
@@ -123,9 +180,9 @@ rc-tabs is released under the MIT license.
123180
124181## FAQ
125182
126- ### Resposive Tabs
183+ ### Responsive Tabs
127184
128- There are 3 cases when handling resposive tabs:
185+ There are 3 cases when handling responsive tabs:
129186![ image] ( https://user-images.githubusercontent.com/27722486/156315099-7e6eda9d-ab77-4b16-9b49-1727c5ec8b26.png )
130187
131188We get hidden tabs through [ useVisibleRange.ts] ( https://github.com/react-component/tabs/blob/master/src/hooks/useVisibleRange.ts ) .
0 commit comments