Badge Overview

The Badge is an absolutely positioned element that is used to decorate avatars, navigation menus, or other components in the application when the visual notification is needed.

It also provides customizing its content through templates, setting different types and layouts.

Initializing the Badge

To initialize the Badge, you can use virtually any span element. The following example demonstrates how to initialize the Badge.

    <a class="k-button"><span id="badge">42</span></a>

    <script>
        $(document).ready(function(){
            $("#badge").kendoBadge({
                appearance: "rectangle"
            });
        });
    </script>

Basic Configuration

The badge also provides the choice to be inline or overlay and set its type. To make the badge overlay add the k-badge-overlay class to the parent parent element.

    <a class="k-button k-badge-overlay"><span id="badge">42</span></a>

    <script>
        $(document).ready(function(){
            $("#badge").kendoBadge({
                appearance: "rectangle",
                type:'warning'
            });
        });
    </script>

Using templates

With the badge you can customize the content using templates.

    <a class="k-button k-badge-overlay"><span id="badge">42</span></a>

    <script>
        $(document).ready(function(){
            $("#badge").kendoBadge({
                appearance: "rectangle",
                type:"info",
                template: "#= +value > 10 ? '9+' : value #"
            });
        });
    </script>

Referencing Existing Instances

You can access an existing Button instance by using the .data() jQuery method which gets executed by the jQuery object of the originating element.

    <a class="k-button k-badge-overlay"><span id="badge">42</span></a>

    <script>
        $(document).ready(function(){
            $("#badge").kendoBadge({
                appearance: "rectangle",
                type:"info"
            });
        });

        var badge = $('#badge').data('kendoBadge');
    </script>

See Also

In this article
Not finding the help you need? Improve this article