mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +08:00
7b771c5db2
* feat: Tabs support indicatorPosition prop * update demo * Update components/tabs/demo/custom-indicator.tsx Co-authored-by: 红 <wxh1220@gmail.com> Signed-off-by: lijianan <574980606@qq.com> * update demo --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: 红 <wxh1220@gmail.com>
49 lines
1014 B
TypeScript
49 lines
1014 B
TypeScript
import React from 'react';
|
|
import { Segmented, Tabs } from 'antd';
|
|
import type { TabsProps } from 'antd';
|
|
|
|
const onChange = (key: string) => {
|
|
console.log(key);
|
|
};
|
|
|
|
const items: TabsProps['items'] = [
|
|
{
|
|
key: '1',
|
|
label: 'Tab 1',
|
|
children: 'Content of Tab Pane 1',
|
|
},
|
|
{
|
|
key: '2',
|
|
label: 'Tab 2',
|
|
children: 'Content of Tab Pane 2',
|
|
},
|
|
{
|
|
key: '3',
|
|
label: 'Tab 3',
|
|
children: 'Content of Tab Pane 3',
|
|
},
|
|
];
|
|
|
|
const App: React.FC = () => {
|
|
const [align, setAlign] = React.useState<TabsProps['indicatorAlign']>('center');
|
|
return (
|
|
<>
|
|
<Segmented
|
|
defaultValue="center"
|
|
style={{ marginBottom: 8 }}
|
|
onChange={(value) => setAlign(value as TabsProps['indicatorAlign'])}
|
|
options={['start', 'center', 'end']}
|
|
/>
|
|
<Tabs
|
|
defaultActiveKey="1"
|
|
items={items}
|
|
onChange={onChange}
|
|
indicatorSize={(origin) => origin - 20}
|
|
indicatorAlign={align}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|