mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-30 20:38:45 +08:00
66 lines
1.4 KiB
TypeScript
66 lines
1.4 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Button, Modal, Space } from 'antd';
|
|
|
|
const App: React.FC = () => {
|
|
const [open, setOpen] = useState(false);
|
|
|
|
const showModal = () => {
|
|
setOpen(true);
|
|
};
|
|
const handleOk = () => {
|
|
setOpen(false);
|
|
};
|
|
|
|
const handleCancel = () => {
|
|
setOpen(false);
|
|
};
|
|
return (
|
|
<>
|
|
<Space>
|
|
<Button type="primary" onClick={showModal}>
|
|
Open Modal
|
|
</Button>
|
|
<Button
|
|
type="primary"
|
|
onClick={() => {
|
|
Modal.confirm({
|
|
title: 'Confirm',
|
|
content: 'Bla bla ...',
|
|
footer: (_, { OkBtn, CancelBtn }) => (
|
|
<>
|
|
<Button>Custom Button</Button>
|
|
<CancelBtn />
|
|
<OkBtn />
|
|
</>
|
|
),
|
|
});
|
|
}}
|
|
>
|
|
Open Modal Confirm
|
|
</Button>
|
|
</Space>
|
|
<Modal
|
|
open={open}
|
|
title="Title"
|
|
onOk={handleOk}
|
|
onCancel={handleCancel}
|
|
footer={(_, { OkBtn, CancelBtn }) => (
|
|
<>
|
|
<Button>Custom Button</Button>
|
|
<CancelBtn />
|
|
<OkBtn />
|
|
</>
|
|
)}
|
|
>
|
|
<p>Some contents...</p>
|
|
<p>Some contents...</p>
|
|
<p>Some contents...</p>
|
|
<p>Some contents...</p>
|
|
<p>Some contents...</p>
|
|
</Modal>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|