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

58 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
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}
items={new Array(3).fill(null).map((_, i) => {
const id = String(i + 1);
return {
label: `Tab ${id}`,
key: id,
children: `Content of Tab ${id}`,
};
})}
/>
</>
);
};
export default App;
2019-05-07 14:57:32 +08:00
```