ant-design/components/tabs/demo/position.md

60 lines
1.4 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 6
2017-02-04 01:13:35 +08:00
title:
zh-CN: 位置
en-US: Position
2016-03-31 09:40:55 +08:00
---
2015-12-16 11:53:52 +08:00
2016-08-03 10:39:20 +08:00
## zh-CN
有四个位置,`tabPosition="left|right|top|bottom"`。在移动端下,`left|right` 会自动切换成 `top`
2015-12-16 11:53:52 +08:00
2016-08-03 10:39:20 +08:00
## en-US
Tab's position: left, right, top or bottom. Will auto switch to `top` in mobile.
2016-08-03 10:39:20 +08:00
```tsx
import type { RadioChangeEvent } from 'antd';
2022-05-23 14:37:16 +08:00
import { Radio, Space, Tabs } from 'antd';
import React, { useState } from 'react';
2018-06-27 15:55:04 +08:00
const { TabPane } = Tabs;
2015-12-16 11:53:52 +08:00
type TabPosition = 'left' | 'right' | 'top' | 'bottom';
const App: React.FC = () => {
const [tabPosition, setTabPosition] = useState<TabPosition>('left');
2018-06-27 15:55:04 +08:00
const changeTabPosition = (e: RadioChangeEvent) => {
setTabPosition(e.target.value);
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
return (
<>
<Space style={{ marginBottom: 24 }}>
Tab position:
<Radio.Group value={tabPosition} onChange={changeTabPosition}>
<Radio.Button value="top">top</Radio.Button>
<Radio.Button value="bottom">bottom</Radio.Button>
<Radio.Button value="left">left</Radio.Button>
<Radio.Button value="right">right</Radio.Button>
</Radio.Group>
</Space>
<Tabs tabPosition={tabPosition}>
<TabPane tab="Tab 1" key="1">
Content of Tab 1
</TabPane>
<TabPane tab="Tab 2" key="2">
Content of Tab 2
</TabPane>
<TabPane tab="Tab 3" key="3">
Content of Tab 3
</TabPane>
</Tabs>
</>
);
};
export default App;
2019-05-07 14:57:32 +08:00
```