17 Feb 20225 minutes to read

The template property can be given as the HTML element; this can be either a string or query selector.

The HTML element tag can be given as a string for the Template property.

template: "<div>Toast Content</div>"

The Template property allows getting the template content using the query selector. Here, the element ‘ID’ attribute is specified in the template.

template: "#Template"
<div style="width:400px;margin:0 auto;">

    <div id="template_toast">
        <ejs-toast id="element" extendedTimeout="0" timeOut="120000">
            <e-toast-position X="Right" Y="Bottom"></e-toast-position>
        <ejs-button id="show_toast" content="Show Toast" cssClass="e-btn"></ejs-button>

    <br /><br />
    <div id='result'></div>

<script id="template_toast_ele" type="text/x-template">
    <div id='template_toast' style="display: none">
        <div class="horizontal-align">
            <div class='toast-content'>
                <div class='toast-title'>
                    Weekend Alarm
                <div class='toast-message'>
                    With traffic, its likely to take 45 minutes to get to jenny's 24th Birthday Bash at Hillside Bar, 454 E.
                    Olive Way by 10:00PM
        <img src="https://ej2.syncfusion.com/demos/src/toast/resource/map.jpg" width="100%" height="70%">

<script type="text/javascript">
        () => {
            var toastObj = document.getElementById('element').ej2_instances[0];
            toastObj.target = document.body;
            toastObj.show({ template: document.getElementById('template_toast_ele').innerHTML });
        }, 1000);
    document.getElementById("show_toast").addEventListener('click', function () {
        var toastObj = document.getElementById('element').ej2_instances[0];
    #dismiss {
        background-color: #fff;

    body > #element .e-toast {
        width: 400px !important;

    .toast-template-section #reminder {
        text-align: center;
        margin: 15px;

    #toast_custom .e-toast-template {
        display: inline-flex;

    #template_toast .toast-icons {
        font-size: 35px;
        height: auto;
        margin: auto;

    #template_toast .toast-icons.e-alarm::before {
        content: "\e702";

    #template_toast .horizontal-align {
        display: inline-flex;
        flex-direction: row;
        width: 100%;

    #template_toast .horizontal-align,
    #template_toast #snoozedropDown,
    #template_toast .snooze,
    #template_toast .snoozeBtn {
        margin: 10px 0;

    #template_toast .horizontal-align .toast-content .toast-title {
        font-weight: 500;

    #template_toast .horizontal-align .toast-content .toast-message {
        opacity: 0.4;

    #template_toast .horizontal-align .toast-content {
        display: inline-flex;
        flex: 1;
        flex-direction: column;
        margin-left: 10px;
public class HomeController : Controller

    public ActionResult Index()
        return View();

Output be like the below.

Toast template

See Also