styled-modal-component
v4.0.0
Published
The bootstrap modal component created with styled-components
Downloads
549
Maintainers
Readme
styled-modal-component
The bootstrap modal component made with styled-components.
This is a modular approach to use bootstrap components for quick prototypes, as an entrypoint of your own component library, or if you need just one bootstrap component for your application.
Installation
npm install --save styled-modal-component
npm install --save styled-components@^4.1.3 react@^16.7.0 # Peer dependenciesUsage
For detailed information take a look at the documentation.
import React, { useState } from 'react';
import {
Modal,
ModalBody,
ModalFooter,
ModalHeader,
ModalTitle,
} from 'styled-modal-component';
export const ModalExample = () => {
const [hidden, setHidden] = useState(true);
return (
<div>
<Modal hidden={hidden} toggle={() => setHidden(!hidden)}>
<ModalHeader>
<ModalTitle>Modal Title</ModalTitle>
<button outline onClick={() => setHidden(!hidden)}>
<span aria-hidden="true">×</span>
</button>
</ModalHeader>
<ModalBody>
Modal body text goes here.
</ModalBody>
<ModalFooter>
<button onClick={() => setHidden(!hidden)}>Close</button>
</ModalFooter>
</Modal>
<button block danger onClick={() => setHidden(!hidden)}>
Launch Modal
</button>
</div>
);
}Properties
Properties which can be added to the component to change the visual appearance.
smonly on Modal Type: booleanlgonly on Modal Type: booleanhiddenonly on Modal Type: booleantoggleonly on Modal Type: functioncenteredonly on Modal Type: booleanbackdroponly on Modal Type: boolean or stringnoRadiusonly on Modal Type: booleanreturnFocusAfterCloseonly on Modal Type: booleantransitionPropsonly on Modal Type: objectwrapperPropsonly on Modal Type: objectdialogPropsonly on Modal Type: objectcontentPropsonly on Modal Type: objectbackdropPropsonly on Modal Type: objectTransitionComponentonly on Modal Type: Component (with forwarded ref)ModalWrapperComponentonly on Modal Type: Component (with forwarded ref)ModalDialogComponentonly on Modal Type: ComponentModalBackdropComponentonly on Modal Type: ComponentModalContentComponentonly on Modal Type: Component
Property
backdropcan be set to false or 'static' to prevent dialog from closing on click outsite of the window.
License
MIT © Lukas Aichbauer
