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

53 lines
864 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-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
2022-05-21 22:14:15 +08:00
import { Button, Drawer } from 'antd';
import React, { useState } from 'react';
2018-05-23 10:56:37 +08:00
const App: React.FC = () => {
const [open, setOpen] = useState(false);
const showDrawer = () => {
setOpen(true);
2018-05-23 10:56:37 +08:00
};
const onClose = () => {
setOpen(false);
2018-05-23 10:56:37 +08:00
};
return (
<>
<Button type="primary" onClick={showDrawer}>
Open
</Button>
<Drawer title="Basic Drawer" placement="right" onClose={onClose} open={open}>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
</>
);
};
2018-05-23 10:56:37 +08:00
export default App;
2018-05-23 10:56:37 +08:00
```
<style>
[data-theme='compact'] .ant-drawer-body p {
margin-bottom: 0;
}
</style>