Skip to content

Commit 0c66625

Browse files
li-jia-nanMadCcc
andauthored
feat: Tab Item support icon prop (#680)
* feat: Tab Item support icon prop * fix: add span Tag for icon * test: update snap * Update src/TabNavList/TabNode.tsx Co-authored-by: MadCcc <[email protected]> * test: update snap --------- Co-authored-by: MadCcc <[email protected]>
1 parent f68f5f4 commit 0c66625

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

docs/examples/basic.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import Tabs from'../../src';
32
import '../../assets/index.less';
3+
import Tabs from '../../src';
44

55
export default () => {
66
const [destroy, setDestroy] = React.useState(false);
@@ -9,17 +9,20 @@ export default () => {
99
label: 'Light',
1010
key: 'light',
1111
children: 'Light!',
12+
icon: <span>🌞</span>,
1213
},
1314
{
1415
label: 'Bamboo',
1516
key: 'bamboo',
1617
children: 'Bamboo!',
18+
icon: <span>🎋</span>,
1719
},
1820
{
1921
label: 'Cute',
2022
key: 'cute',
2123
children: 'Cute!',
2224
disabled: true,
25+
icon: <span>🐼</span>,
2326
},
2427
]);
2528

@@ -38,6 +41,7 @@ export default () => {
3841
key: 'yo',
3942
label: 'Yo',
4043
children: 'Yo!',
44+
icon: <span>👋</span>,
4145
},
4246
]);
4347
}}

src/TabNavList/TabNode.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function TabNode({
2424
prefixCls,
2525
id,
2626
active,
27-
tab: { key, label, disabled, closeIcon },
27+
tab: { key, label, disabled, closeIcon, icon },
2828
closable,
2929
renderWrapper,
3030
removeAriaLabel,
@@ -87,6 +87,7 @@ function TabNode({
8787
}}
8888
onFocus={onFocus}
8989
>
90+
{icon && <span className={`${tabPrefix}-icon`}>{icon}</span>}
9091
{label}
9192
</div>
9293

src/TabPanelList/TabPane.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as React from 'react';
21
import classNames from 'classnames';
2+
import * as React from 'react';
33

44
export interface TabPaneProps {
55
tab?: React.ReactNode;
@@ -10,6 +10,7 @@ export interface TabPaneProps {
1010
forceRender?: boolean;
1111
closable?: boolean;
1212
closeIcon?: React.ReactNode;
13+
icon?: React.ReactNode;
1314

1415
// Pass by TabPaneList
1516
prefixCls?: string;

tsconfig.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@
2323
]
2424
}
2525
},
26-
"include": [".dumi/**/*", ".dumirc.ts", "**/*.ts", "**/*.tsx"]
27-
}
26+
"include": [
27+
".dumirc.ts",
28+
"**/*.ts",
29+
"**/*.tsx"
30+
]
31+
}

0 commit comments

Comments
 (0)