ant-design/components/tabs/demo/position.md
二货爱吃白萝卜 628968f460
feat: Tabs support items (#36889)
* refactor: Using items

* docs: replace with items

* docs: deprecated demo

* test: Update snapshot

* docs: simple basic demo

* test: coverage
2022-08-05 10:49:08 +08:00

58 lines
1.4 KiB
Markdown

---
order: 6
title:
zh-CN: 位置
en-US: Position
---
## zh-CN
有四个位置,`tabPosition="left|right|top|bottom"`。在移动端下,`left|right` 会自动切换成 `top`
## en-US
Tab's position: left, right, top or bottom. Will auto switch to `top` in mobile.
```tsx
import type { RadioChangeEvent } from 'antd';
import { Radio, Space, Tabs } from 'antd';
import React, { useState } from 'react';
type TabPosition = 'left' | 'right' | 'top' | 'bottom';
const App: React.FC = () => {
const [tabPosition, setTabPosition] = useState<TabPosition>('left');
const changeTabPosition = (e: RadioChangeEvent) => {
setTabPosition(e.target.value);
};
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;
```