Getting Started
Dark Mode
Charts
Colors
Drag-and-drop
Forms
Utilities
Basic
A modal is a pop-up window that demands your attention. You have to deal with it before doing anything else on the page.
Installation
If you hit any issues, make sure you check out the installation guide here for more information.
Composed Components
Plug this component into the CLI, and it automatically loads all the included components. No need to add them individually.
The Modal comes packed with a variety of components to make it stand out.
Manual Installation
Sometimes, using the CLI is the way to go, so make sure you install the necessary dependencies for the components you want to use.
Anatomy
Alert Dialog
Alert dialogs are meant to interrupt the user with a critical message, so use 'em only when it's absolutely necessary. The fix? Set the role to alertdialog
, and you're golden.
Notice how the modal is dismissable and the close button is hidden? That's 'cause the role is set to alertdialog
.
Controlled
You can control the modal programmatically.
Sizes
The modal is set to lg
by default. You can adjust it to any size from the available options.
Blur
If you want to blur the background, you can use isBlurred
prop.
Sticky
You can use the Modal.Body
component to make the modal sticky.
Nested
You can also nest modals. Try open it and confirm!
Header
This setup’s super flexible. If you skip adding ModalTitle
and just drop a string as its child, it'll auto-render as the title. Like this:
Wanna customize more? Throw in props like title
and description
for a tailored header:
Custom Styles
To apply custom styles such as background colors or borders to the header, follow this guide:
Class Names
To add custom class names to your content or overlay, refer to this demonstration:
Triggered By Menu
You can also trigger the modal by clicking on a menu item.
It might be a good idea to extract the modal into a separate component for better organization.
Then you can use it like this.
With that, now we can modify the actionType
function to return the initial state.