uwc-badge code examples, properties, methods, events and Live Demo.

Here is an example of using the Badge in a plain html page:

<html>
<head>
<link href="https://developer.temenos.com/uux/base.css" rel="stylesheet" />
<script src="https://developer.temenos.com/uux/unified-ux-web.min.js"></script>
</head>
<body>
<uwc-badge id="notificationBadge" content="xxx" color="temenos-primary">
<uwc-icon-button id="notificationButton" icon="notifications" color="temenos-dark"></uwc-icon-button>
</uwc-badge>
<script>
const badge = document.getElementById('notificationBadge');
const button = document.getElementById('notificationButton');
console.log('Badge element:', badge);
console.log('Button element:', button);
let count = 4;
// Toggle visibility based on count
function updateBadge() {
console.log('Updating badge count:', count);
badge.setAttribute('content', count);
if (count === 0) {
console.log('Hiding badge');
badge.setAttribute('invisible', '');
} else {
console.log('Showing badge');
badge.removeAttribute('invisible');
}
}
// Example: Decrease count on button click
button.addEventListener('click', () => {
console.log('Button clicked');
count = count - 1;
updateBadge();
});
updateBadge();
</script>
</body>
</html>