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

61 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
2019-05-07 14:57:32 +08:00
```jsx
import { Tabs, Radio, Space } from 'antd';
2018-06-27 15:55:04 +08:00
const { TabPane } = Tabs;
2015-12-16 11:53:52 +08:00
class Demo extends React.Component {
state = {
tabPosition: 'left',
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
changeTabPosition = e => {
this.setState({ tabPosition: e.target.value });
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
2015-12-16 11:53:52 +08:00
render() {
const { tabPosition } = this.state;
return (
<>
<Space style={{ marginBottom: 24 }}>
Tab position:
<Radio.Group value={tabPosition} onChange={this.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}>
2019-05-07 14:57:32 +08:00
<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>
</>
);
}
}
2015-12-16 11:53:52 +08:00
export default Demo;
2019-05-07 14:57:32 +08:00
```