Even though badges come with 8 predefined colors
, you can also customize the colour of the badge as desired.
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 for Badge </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential JS 2 for Badge UI Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-base/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-notifications/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element">
<h1>Color Customization <span class="e-badge e-badge-primary e-badge-pill green">New</span></h1>
<h1>Color Customization <span class="e-badge e-badge-primary e-badge-pill bue">New</span></h1>
<h1>Color Customization <span class="e-badge e-badge-primary e-badge-pill purple">New</span></h1>
<h1>Color Customization <span class="e-badge e-badge-primary e-badge-pill gradient">New</span></h1>
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Badges are designed to change its size based on the content. To change the size of a badge, adjust the font size
of the badge.
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 for Badge </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential JS 2 for Badge UI Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-base/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-notifications/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element">
<h1>Badge Component <span class="e-badge e-badge-primary size_1">New</span></h1>
<h1>Badge Component <span class="e-badge e-badge-primary size_2">New</span></h1>
<h1>Badge Component <span class="e-badge e-badge-primary size_3">New</span></h1>
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Even though the badges support the conventional top
and bottom
positions, the position of the badges can be changed as desired.
This can be done by adding a custom class to the badge element to override the default position applied from the source.
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 for Badge </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential JS 2 for Badge UI Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-base/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-notifications/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element">
<div style="width: 200px;margin: 10px auto;">
<div class="badge-block">
<div class="whatsapp svg_icons"></div>
<!-- Warning Colored Notification Badge -->
<span class="e-badge e-badge-warning e-badge-notification e-badge-overlap leftTop">99+</span>
</div>
<div class="badge-block">
<div class="facebook svg_icons"></div>
<!-- Danger Colored Notification Badge -->
<span class="e-badge e-badge-danger e-badge-notification e-badge-overlap leftTop">99+</span>
</div>
<div class="badge-block">
<div class="skype svg_icons"></div>
<!-- Secondary Colored Notification Badge -->
<span class="e-badge e-badge-secondary e-badge-notification e-badge-overlap leftTop">18</span>
</div>
</div>
<div style="width: 200px;margin: 10px auto;">
<div class="badge-block">
<div class="whatsapp svg_icons"></div>
<!-- Warning Colored Notification Badge -->
<span class="e-badge e-badge-warning e-badge-notification e-badge-overlap leftBottom">99+</span>
</div>
<div class="badge-block">
<div class="facebook svg_icons"></div>
<!-- Danger Colored Notification Badge -->
<span class="e-badge e-badge-danger e-badge-notification e-badge-overlap leftBottom">99+</span>
</div>
<div class="badge-block">
<div class="skype svg_icons"></div>
<!-- Secondary Colored Notification Badge -->
<span class="e-badge e-badge-secondary e-badge-notification e-badge-overlap leftBottom">18</span>
</div>
</div>
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>