Toast

The Toast is a widget that provides pop-up notifications.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/toast
Export: default
Toast interactive configuration
Copy Code
Copy to Codepen
$("#toast").dxToast({
});

                    

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the Toast widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

jQuery
JavaScript
HTML
$(function() {
    $("#toast").dxToast({
        message: "Connection problem",
        type: "error",
        displayTime: 3000
    });
    $("#button").dxButton({
        text: "Show the Toast", 
        onClick: function () {
            $("#toast").dxToast("show");
        } 
    });
});
<div id="toast"></div>
<div id="button"></div>
Angular
HTML
TypeScript
<dx-toast
    message="Connection problem"
    type="error"
    [displayTime]="3000"
    [(visible)]="isToastVisible">
</dx-toast>
<dx-button
    text="Show the Toast" 
    (onClick)="showToast()">
</dx-button>
import { DxToastModule } from 'devextreme-angular'
// ...
export class AppComponent {
    isToastVisible = false;
    showToast() {
        this.isToastVisible = true;
    }
}
@NgModule({
    imports: [
        // ...
        DxToastModule
    ],
    // ...
})
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-toast="{
        message: 'Connection problem',
        type: 'error',
        displayTime: 3000,
        bindingOptions: {
            visible: 'isToastVisible'
        } 
    }"></div>
    <div dx-button="{
        text: 'Show the Toast', 
        onClick: showToast
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.isToastVisible = false;
        $scope.showToast = function () {
            $scope.isToastVisible = true
        };
    });
Knockout
HTML
JavaScript
<div data-bind="dxToast: {
    message: 'Connection problem',
    type: 'error',
    displayTime: 3000,
    visible: isToastVisible
}"></div>
<div data-bind="dxButton: {
    text: 'Show the Toast', 
    onClick: showToast
}"></div>
var viewModel = {
    isToastVisible: ko.observable(false),
    showToast: function (e) {
        e.model.isToastVisible(true);
    }
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().Toast()
    .ID("toast")
    .Message("Connection problem")
    .Type(ToastType.Error)
    .DisplayTime(3000)
)
@(Html.DevExtreme().Button()
    .ID("button")
    .Text("Show the Toast")
    .OnClick(@<text>
        function (e) {
            $("#toast").dxToast("show")
        }
    </text>)    
)
@(Html.DevExtreme().Toast() _
    .ID("toast") _
    .Message("Connection problem") _
    .Type(ToastType.Error) _
    .DisplayTime(3000)
)
@(Html.DevExtreme().Button() _
    .ID("button") _
    .Text("Show the Toast") _
    .OnClick("button_click")    
)
<script>
    function button_click(e) {
        $("#toast").dxToast("show")
    }
</script>

View Demo

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the Toast widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

See Also