mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 13:37:52 +08:00
ca39a4b1ee
* refactor: refactor indicator props * Update components/tabs/index.tsx Co-authored-by: afc163 <afc163@gmail.com> Signed-off-by: lijianan <574980606@qq.com> * fix: update * fix: fix * fix: fix * fix: fix * fix: fix * test: add test case * docs: update docs * Update components/config-provider/index.en-US.md Co-authored-by: MadCcc <madccc@foxmail.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/config-provider/index.zh-CN.md Co-authored-by: MadCcc <madccc@foxmail.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/tabs/index.tsx Co-authored-by: MadCcc <madccc@foxmail.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/tabs/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/tabs/index.zh-CN.md Co-authored-by: MadCcc <madccc@foxmail.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/tabs/index.en-US.md Co-authored-by: MadCcc <madccc@foxmail.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/tabs/index.zh-CN.md Co-authored-by: MadCcc <madccc@foxmail.com> Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: MadCcc <madccc@foxmail.com>
38 lines
976 B
TypeScript
38 lines
976 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' },
|
|
];
|
|
|
|
type Align = 'start' | 'center' | 'end';
|
|
|
|
const App: React.FC = () => {
|
|
const [alignValue, setAlignValue] = React.useState<Align>('center');
|
|
return (
|
|
<>
|
|
<Segmented
|
|
defaultValue="center"
|
|
style={{ marginBottom: 8 }}
|
|
onChange={(value) => setAlignValue(value as Align)}
|
|
options={['start', 'center', 'end']}
|
|
/>
|
|
<Tabs
|
|
defaultActiveKey="1"
|
|
items={items}
|
|
onChange={onChange}
|
|
indicator={{ size: (origin) => origin - 20, align: alignValue }}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|