mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
1919b5f7d9
Co-authored-by: 二货机器人 <smith3816@gmail.com>
1.5 KiB
1.5 KiB
order | title | ||||
---|---|---|---|---|---|
10 |
|
zh-CN
抽屉的默认宽度为 378px
,另外还提供一个大号抽屉 736px
,可以用 size
属性来设置。
en-US
The default width (or height) of Drawer is 378px
, and there is a presetted large size 736px
.
import { Button, Drawer, Space } from 'antd';
import type { DrawerProps } from 'antd/es/drawer';
import React, { useState } from 'react';
const App: React.FC = () => {
const [open, setOpen] = useState(false);
const [size, setSize] = useState<DrawerProps['size']>();
const showDefaultDrawer = () => {
setSize('default');
setOpen(true);
};
const showLargeDrawer = () => {
setSize('large');
setOpen(true);
};
const onClose = () => {
setOpen(false);
};
return (
<>
<Space>
<Button type="primary" onClick={showDefaultDrawer}>
Open Default Size (378px)
</Button>
<Button type="primary" onClick={showLargeDrawer}>
Open Large Size (736px)
</Button>
</Space>
<Drawer
title={`${size} Drawer`}
placement="right"
size={size}
onClose={onClose}
open={open}
extra={
<Space>
<Button onClick={onClose}>Cancel</Button>
<Button type="primary" onClick={onClose}>
OK
</Button>
</Space>
}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
</>
);
};
export default App;