Toast Configuration

An object defining configuration options for the dxToast widget.

animation

An object defining animation options of the widget.

Type: Object

See the UI Widgets topic to learn how to configure animation options used to show and hide the widget.

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Show toast', clickAction: showToast }"></div>
<div class="dx-fieldset">
  <div class="dx-field">
    <div style="width: 60%" class="dx-field-label">Animation Type</div>
    <div style="width: 40%" class="dx-field-value" data-bind="dxLookup: {
      dataSource: animationTypes,
      value: animationType,
      valueChangeAction: typeChanged
    }"></div>
  </div>
</div>
<div id="toastContainer" data-bind="dxToast: { 
  message: 'Toast message', 
  animation: animationConfig
}"></div>
animationTypes = [
  "fade",
  "pop",
  "slide"
];
animationType = ko.observable(animationTypes[0]);
animationConfig = ko.observable({});
typeChanged = function () {
  switch (animationType()) {
    case "slide":
      animationConfig({
        show: { type: "slide", from: { opacity: 1, top: $(window).height() }, to: { top: $(window).height() - 200 } },
        hide: { type: "slide", from: { top: $(window).height() - 200 }, to: { top: $(window).height() } }
      });
      break;
    case "pop":
      animationConfig({
        show: { type: "pop", from: { opacity: 1, scale: 0 }, to: { scale: 1 } },
        hide: { type: "pop", from: { scale: 1 }, to: { scale: 0 } }
      });
      break;
    case "fade":
      animationConfig({
        show: { type: "fade", from: 0, to: 1 },
        hide: { type: "fade", from: 1, to: 0 }
      });
      break;
    default:
      animationConfig({});
  }
}
showToast = function () {
  $("#toastContainer").dxToast("instance").show();
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

clickAction

An action performed when the widget is clicked.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div id="toastContainer" data-bind="dxToast: {
  message: 'Click this toast',
  type: 'Success',
  displayTime: 5000,
  clickAction: processClick
}"></div>
showToast = function () {
  $("#toastContainer").dxToast('instance').show();
};
processClick = function () {
  DevExpress.ui.dialog.alert("The widget has been clicked", "Click notification");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

closeOnOutsideClick

A Boolean value specifying whether or not the widget is closed if a user clicks outside of the overlaying window.

Type: Boolean
Default Value: false

displayTime

The time span in milliseconds during which the dxToast widget is visible.

Type: Number
Default Value: 2000

height

The height of the widget in pixels.

Type: Number|String|function
Default Value: function() { return $(window).height() * 0.8 }

The option can hold a value of the following types.

  • numeric - the height of the widget in pixels
  • string - a CSS measurement of the widget height (e.g., "55px", "80%", "auto" and "inherit")
  • function - a function returning the widget height (e.g., height:function(){ return baseHeight - 10 + "%"; })

hiddenAction

An action performed after the widget is hidden.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    hiddenAction: processHiding
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processHiding = function () {
  DevExpress.ui.dialog.alert("The widget has been hidden", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

hiddingAction

An action performed before hiding the widget.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    hiddingAction: processHiding
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processHiding = function () {
  DevExpress.ui.dialog.alert("The widget is being hidden", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

message

The dxToast message text.

Type: String
Default Value: ""

position

An object defining widget positioning options.

Type: Object

The postion option takes on an object containing the following fields: my, at, of and offset. Look at the following sentence to see how to use these fields to position the required element against the target element.

"Place my 'left' side at the 'left bottom' corner of the '#targetElement'." The bold quoted phrase located after each option name within the sentence represents a value of the appropriate option.

The offset field takes on a string containing horizontal and vertical offset values (in pixels) separated by space.

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Show toast', clickAction: showToast }"></div>
<p style="text-align:center"><b>Position</b></p>
<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">my</div>
    <div class="dx-field-value" data-bind="dxLookup: { dataSource: positionValues, value: myValue }"></div>
  </div>
  <div class="dx-field">
    <div class="dx-field-label">at</div>
    <div class="dx-field-value" data-bind="dxLookup: { dataSource: positionValues, value:atValue }"></div>
  </div>
  <div class="dx-field">
    <div class="dx-field-label">offset</div>
    <div class="dx-field-value" data-bind="dxTextBox: { value: offsetValue }"></div>
  </div>
</div>
<div id="targetElement"></div>
<div id="toastContainer" data-bind="dxToast: { 
  message: 'Toast message', 
  displayTime:2000, 
  position: {
    my: myValue(),
    at: atValue(),
    of: $('#targetElement'),
    offset: offsetValue()
  }
}"></div>
atValue = ko.observable("bottom");
myValue = ko.observable("bottom");
offsetValue = ko.observable("0 0");
showToast = function () {
  $("#toastContainer").dxToast("instance").show();
};
positionValues = [
  "left top",
  "top",
  "right top",
  "right",
  "right bottom",
  "bottom",
  "left bottom",
  "left",
  "center"
];
body{
  text-align: center;
}
.button{
  margin: 10px;
}
#targetElement {
  display: inline-block;
  width: 80%;
  height: 170px;
  border-style: solid;
  background-color: lightgreen;
}

shading

A Boolean value specifying whether or not to shade the screen beneath the overlay.

Type: Boolean
Default Value: false

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">Shading</div>
    <div class="dx-field-value" data-bind="dxCheckBox: { checked: enableShading }"></div>
  </div>
</div>
<div id="toastContainer" data-bind="dxToast: { message: 'The toast message', type: 'success', displayTime: 1000, shading: enableShading }"></div>
enableShading = ko.observable(false);
showToast = function () {
  $("#toastContainer").dxToast('instance').show();
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

showingAction

An action performed before showing the overlay.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    showingAction: processShowing
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processShowing = function () {
  DevExpress.ui.dialog.alert("The widget is being shown", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

shownAction

An action performed after the widget is shown.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    showingAction: processShowing
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processShowing = function () {
  DevExpress.ui.dialog.alert("The widget has been shown", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

type

Specifies the dxToast widget type.

Type: String
Default Value: 'info'
Accepted Values: 'info'|'warning'|'error'|'success'|'custom'

The available toast types (except for "custom") only differ by the icon and background color.

If you assign "custom" to the type option, the dx-toast-custom class is applied to the widget element. Implement the appropriate CSS class to specify toast appearance.

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Show toast', clickAction: showToast }"></div>
<div class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">Type</div>
        <div class="dx-field-value" data-bind="dxLookup: { dataSource: toastTypes, value: currentType }"></div>
    </div>
</div>
<div id="toastContainer" data-bind="dxToast: { message: 'The toast message', type: currentType, displayTime: 3000 }">
</div>
<div id="customToastContainer" data-bind="dxToast: { type: 'custom', displayTime: 3000 }">
  The custom toast message!<br/>
  <div class="dx-icon dx-icon-toolbox"></div>
</div>
showToast = function () {
  if (currentType() == 'custom')
    $("#customToastContainer").dxToast('instance').show();
  else
    $("#toastContainer").dxToast('instance').show();
};
processClick = function () {
  DevExpress.ui.dialog.alert("The widget has been clicked", "Click notification");
};
toastTypes = [
  "info",
  "warning",
  "error",
  "success",
  "custom"
];
currentType = ko.observable(toastTypes[0]);
body{
  text-align: center;
}
.button{
  margin: 10px;
}
.dx-theme-ios .dx-toast .dx-toast-custom{
  background-color: orange;
  font-size: 28px;
}
.dx-theme-android .dx-toast .dx-toast-custom{
  background-color: #616161;
  font-size: 28px;
}
.dx-theme-win8 .dx-toast .dx-toast-custom{
  background-color: gray;
  font-size: 28px;
}
.dx-icon {
  display: inline-block;
  height: 56px;
  width: 56px;
  vertical-align: middle;
}

visible

A Boolean value specifying whether or not the widget is visible.

Type: Boolean
Default Value: false

You can show and hide the widget by changing the value of an observable variable passed to this option.

Show Example:
jQuery
<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">Visible</div>
    <div class="dx-field-value" data-bind="dxCheckBox: { checked: toastVisible }"></div>
  </div>
</div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000
}"></div>
toastVisible = ko.observable(false);
body{
  text-align: center;
}

width

The widget width in pixels.

Type: Number|String|function
Default Value: function() {return $(window).width() * 0.8 }

The option can hold a value of the following types.

  • numeric - the widget width in pixels
  • string - a CSS measurement of the widget width (e.g., "55px", "80%", "auto" and "inherit")
  • function - the function returning the widget width (e.g., width:function(){ return baseWidth - 10 + "%"; })