ant-design/components/drawer/demo/basic-right.md

56 lines
957 B
Markdown
Raw Normal View History

2018-05-23 10:56:37 +08:00
---
order: 0
title:
2018-06-22 15:46:21 +08:00
zh-CN: 基础抽屉
2018-05-23 10:56:37 +08:00
en-US: Basic
---
## zh-CN
2018-06-22 15:46:21 +08:00
基础抽屉,点击触发按钮抽屉从右滑出,点击遮罩区关闭
2018-05-23 10:56:37 +08:00
## en-US
2018-05-23 11:13:50 +08:00
Basic drawer.
2018-05-23 10:56:37 +08:00
```tsx
import React, { useState } from 'react';
2018-05-23 10:56:37 +08:00
import { Drawer, Button } from 'antd';
const App: React.FC = () => {
const [visible, setVisible] = useState(false);
const showDrawer = () => {
setVisible(true);
2018-05-23 10:56:37 +08:00
};
const onClose = () => {
setVisible(false);
2018-05-23 10:56:37 +08:00
};
return (
<>
<Button type="primary" onClick={showDrawer}>
Open
</Button>
<Drawer
title="Basic Drawer"
placement="right"
closable={false}
onClose={onClose}
visible={visible}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
</>
);
};
2018-05-23 10:56:37 +08:00
ReactDOM.render(<App />, mountNode);
```
<style>
[data-theme='compact'] .ant-drawer-body p {
margin-bottom: 0;
}
</style>