- The Modal component in Materialize CSS
- The example of simple modal
- Materialize css модальное окно
- Modal Header
- Modal Header
- Modal Header
- Modals with Button trigger
- Initialization
- Options
- Methods
- Materialize Css Modal Popup
- Materialize Css Modal Popup Example
- Example:
- Modal Fixed Footer
- Example:
- jQuery Initialization
- Open Modal
- Close Model
- Options
- Example:
- Lorem ipsum
- Paralax Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita, blanditiis, deserunt dolor sit magnam a at voluptatibus officia reiciendis aspernatur.
- Modal header
- Lorem ipsum
- Paralax Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita, blanditiis, deserunt dolor sit magnam a at voluptatibus officia reiciendis aspernatur.
The Modal component in Materialize CSS
The Materialize CSS has a built-in modal component that you may use easily for creating dialog boxes or presenting important content to the visitors where underlying content becomes inactive until the modal window is closed.
The modal can be closed by clicking anywhere outside the modal window or using the close button within the modal. So, you may also use modal for the confirmation messages.
Creating materialize modal is easy and require a few line of codes of HTML and jQuery. In order to modal component work, you need to include the reference to materialize.min.js along with jQuery on the web page.
The following section shows how to create modal using materialize framework with live demo and code snippets.
The example of simple modal
A basic modal contains content and footer. The modal-content class is referred to the main div where you may provide the header and content for the modal.
Use the modal-footer class in another div where close button along with other action buttons can be used. Have a look at the markup, jQuery code and working modal by clicking the link or image below:
See online demo and code
The markup for the modal:
Materialize css модальное окно
Use a modal for dialog boxes, confirmation messages, or other content that can be called up. In order for the modal to work you have to add the Modal ID to the link of the trigger. To add a close button, just add the class .modal-close to your button.
Modal Header
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
Modal Header
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
Modal Header
- Title First Line
Second Line grade - folder Title First Line
Second Line grade - assessment Title First Line
Second Line grade - play_arrow Title First Line
Second Line grade
Modal Modal Header
A bunch of text
Agree
Modals with Button trigger
If you prefer to use a button to open a modal specify the Modal ID in data-target rather than the href attribute.
Initialization
To open a modal using a trigger:
document.addEventListener('DOMContentLoaded', function() < var elems = document.querySelectorAll('.modal'); var instances = M.Modal.init(elems, options); >); // Or with jQuery $(document).ready(function()< $('.modal').modal(); >);
Options
You can customize the behavior of each modal using these options. For example, you can call a custom function to run when a modal is dismissed. To do this, just place your function in the intialization code as shown below.
Name | Type | Default | Description |
---|---|---|---|
opacity | Number | 0.5 | Opacity of the modal overlay. |
inDuration | Number | 250 | Transition in duration in milliseconds. |
outDuration | Number | 250 | Transition out duration in milliseconds. |
onOpenStart | Function | null | Callback function called before modal is opened. |
onOpenEnd | Function | null | Callback function called after modal is opened. |
onCloseStart | Function | null | Callback function called before modal is closed. |
onCloseEnd | Function | null | Callback function called after modal is closed. |
preventScrolling | Boolean | true | Prevent page from scrolling while modal is open. |
dismissible | Boolean | true | Allow modal to be dismissed by keyboard or overlay click. |
startingTop | String | ‘4%’ | Starting top offset |
endingTop | String | ‘10%’ | Ending top offset |
Methods
Because jQuery is no longer a dependency, all the methods are called on the plugin instance. You can get the plugin instance like this:
var instance = M.Modal.getInstance(elem); /* jQuery Method Calls You can still use the old jQuery plugin method calls. But you won't be able to access instance properties. $('.modal').modal('methodName'); $('.modal').modal('methodName', paramName); */
.open();
Materialize Css Modal Popup
Materialize Css provides predefined classes to create beautiful modals. Materialize Css Modal Popup are used widely in any application so it is important to understand how we can use these popups. Here in this tutorial, we are going to explain how to create modal popup in Materialize css framework. You can also use our online editor to edit and run the code online.
Materialize Css Modal Popup Example
Class modal is used to define the modal, Class modal-content is used to define the content body. Class modal-footer defines the modal footer. Here is an example of Materialize modal popup.-
Example:
ModalTutorialsplane.comLearn more @ tutorialsplane.com!
Close