The Wayback Machine - https://web.archive.org/web/20240714091342/https://www.geeksforgeeks.org/explain-dialogs-in-materialize-css/
Open In App

Explain Dialogs in Materialize CSS

Last Updated : 07 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Dialogs in Materialize CSS provide users additional information to users if needed by them. These are directly not visible on the web-page. The dialog transitions are related to the information that is required at that point of time. Materialize provides various methods to show dialogs.

Syntax:

Materialize.toast(string, time, styleClass,callback);

Parameters:

  • string: It is the string that needs to be displayed in the dialog.
  • time: It is the time for what message string would be shown.
  • style class: This is to add various styles.
  • callback: This callback is a method to be called once the toast is discharged.

Linked Files: Include materialize and jQuery CDN into the <head> tag before all other stylesheets to load our CSS and JavaScript.

<link rel = “stylesheet” href = “https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css”>
<script type = “text/javascript” src = “https://code.jquery.com/jquery-2.1.1.min.js”></script>
<script src = “https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js”></script>

Example: The below example shows the implementation of dialogs in Materialize CSS.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" href=
    <script type="text/javascript" 
    <script src=
    </script>
  
    <script>
        function Toast1(string, timeLength) {
            Materialize.toast(
                '<em>' + string + '</em>', timeLength
            );
        }
        function Toast2(string, timeLength) {
            Materialize.toast(
                '<b>' + string + '</b>', timeLength, 'rounded'
            );
        }
        function Toast3(string, timeLength) {
            Materialize.toast(
                '<u>' + string + '<u>', timeLength
            );
        }
    </script>
</head>
  
<body>
    <body class="container">
        <h4>Toasts</h4>
        <a class="btn" onclick=
            "Toast1('Emphasized Alert!', 1500)">
            Emphasized Alert!!
        </a><br><br>
  
        <a class="btn" onclick=
            "Toast2('Bold N rounded Alert!', 1500)">
            Bold N rounded Alert!!
        </a><br><br>
  
        <a class="btn" onclick=
            "Toast3('Underlined Alert!', 1500)">
            Underlined Alert!!
        </a><br><br>
    </body>
</body>
  
</html>


Output:



Similar Reads

Explain Badge in Materialize CSS ?
Badges are one of the very useful components of Materialize CSS. It is like an icon and helps us to display things like unread messages, notifications, emails, and all other such things. In this article, we will discuss how to use the badge in Materialize CSS. A badge can be defined by adding the badge class inside a span element. We can add a back
3 min read
React Suite Modal Alert dialogs
React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application. In this article, we'll learn about React suite Modal alert dialogs. Alert dialogs are useful interruptions when a s
5 min read
Materialize CSS Preloader
Preloaders are used for providing symbolic messages that tells users about the website status like "Loading" or "Not crashed". Materialize provides CSS classes to give various types of preloaders. The following are the available classes provided by Materialize CSS. Linear: It identifies an element as a progress bar class required for "div" element.
5 min read
Materialize CSS Colors
It is created with HTML, CSS, and JavaScript, and designed by Google. Material Design is a design language that combines the classic principles of successful design along with innovation and technology. Color: Here is a color palette based on the material design base colors. Each of these colors is defined with a base color class and an optional li
2 min read
Materialize CSS Grids
There are 12 standard columns fluid responsive grid systems that helps you to layout your page in an ordered and easy way. It uses the row and column style classes to define rows and columns respectively. Rows are used to specify a padding-less container to be used for responsive columns and col are used to specify a column with sub-classes. There
3 min read
Materialize CSS | Tables
Tables are nice and easy way to organize a lot of data. Materialize CSS provides a few utility classes to style table. In addition to improve mobile experience, all tables on mobile-screen widths are centered automatically. Following are the styles for table: Stripped Table: C/C++ Code &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html&amp;gt; &amp;lt;head
3 min read
Materialize CSS Helpers
There are several helpers in materialize CSS that are used for designing needs such as: AlignmentHiding/Showing contentFormatting 1. Alignment: Content can be aligned horizontally or vertically by using the following classes: Vertical Align: It can be easily done by adding the class valign-wrapper to the container holding the items that you want to
3 min read
Materialize CSS Badges
Materialize badge is a component that is used to notify, if there are new or unread messages or notifications display. Adding a new class to a badge component gives it a background. There are different ways of using badge component: Badges in Collections: &lt;div class="collection"&gt; &lt;a href="#!" class="collection-item"&gt;&lt;span class="badg
4 min read
Materialize CSS Breadcrumbs
Breadcrumbs in materialize CSS is used when you have multiple layers of content to display your current location. Materialize CSS provides various CSS classes to create a nice breadcrumb in an easy way. It uses two classes i.e. nav-wrapper and breadcrumb. nav-wrapper is used to set the nav component as breadcrumb/nav bar wrapper. breadcrumb is used
1 min read
Materialize CSS Media
Various classes are provided by materialize CSS to make media responsive. Images: Images can be styled in following ways: Responsive Images: To make images responsive to page width, responsive-img class is added with image tag. &lt;img class="responsive-img" src="image.jpg"&gt; Circular Images: To make image look circular, circle class is added wit
2 min read
three90RightbarBannerImg