Modal
Modals provide a way to display dialogs to your users.
Examples
import React from 'react';
import ReactDOM from 'react-dom';
import { ModalCenter, Modal, ModalSection, Button } from 'furl-components';
const modalCenterRef = React.createRef();
ReactDOM.render(
<div>
<ModalCenter ref={modalCenterRef} />
<Button color='primary' onClick={() => {
modalCenterRef.current.setContent(
<Modal>
<ModalSection>
<h5>Howdy, there!</h5>
<p>Nice to see you here. You can learn more about our website by visiting more pages.</p>
<Button color='primary' onClick={() => modalCenterRef.current.hide()}>Take me back</Button>
</ModalSection>
</Modal>
);
modalCenterRef.current.show();
}}>Open modal dialog</Button>
</div>,
document.getElementById('root')
);
API
Property | Description | Type | Default | ||
---|---|---|---|---|---|
ref | modal center ref | React Ref | |||
isOpen | modal center open state | boolean | false |
Method | Description | ||
---|---|---|---|
setContent() | set content of the modal center | ||
show() | show content of the modal center | ||
hide() | hide content of the modal center |
Property | Description | Type | Default | ||
---|---|---|---|---|---|
media | modal section media url | string | |||
height | modal section height | int/string | 'auto' |
Notes
- It is highly recommended to provide a
ref
for yourModalCenter
via the use ofReact.createRef()
.ModalCenter
should only be used once in your app and it should be reused viaref.current
for multiple modal dialogs. - A
ModalCenter
only accepts children of theModal
component type, set either normally or via thesetContent
method. - A
Modal
only accepts children of theModalSection
component type. - The
ModalSection
’sheight
accepts any valid CSS value, including CSS variables, and will only be applied ifmedia
is specified. - If a
ModalSection
has amedia
prop specified, it should not have any children.