You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
882 B

7 years ago
---
order: 0
title:
7 years ago
zh-CN: 基础抽屉
7 years ago
en-US: Basic
---
## zh-CN
基础抽屉,点击触发按钮抽屉从右滑出,点击遮罩区关闭。
7 years ago
## en-US
Basic drawer.
7 years ago
```tsx
import { Button, Drawer } from 'antd';
import React, { useState } from 'react';
7 years ago
const App: React.FC = () => {
const [visible, setVisible] = useState(false);
const showDrawer = () => {
setVisible(true);
7 years ago
};
const onClose = () => {
setVisible(false);
7 years ago
};
return (
<>
<Button type="primary" onClick={showDrawer}>
Open
</Button>
<Drawer title="Basic Drawer" placement="right" onClose={onClose} visible={visible}>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
</>
);
};
7 years ago
export default App;
7 years ago
```
<style>
[data-theme='compact'] .ant-drawer-body p {
margin-bottom: 0;
}
</style>