Skip to content

Badge Notification Library for MAUI applications

License

Notifications You must be signed in to change notification settings

TheEightBot/EightBot.Maui.Badger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EightBot.Maui.Badger Logo

EightBot.Maui.Badger

A .NET MAUI library for adding badges to TabbedPage tabs with support for custom colors.

Build and Publish NuGet License: MIT

Features

  • 🏷️ Badge Text - Display text or numbers on tab badges
  • 🎨 Custom Colors - Customize badge background and text colors
  • 📱 Cross-Platform - Supports Android, iOS, and MacCatalyst

Platform Support

Platform Support
Android
iOS
MacCatalyst
Windows 🚧

Installation

Install via NuGet Package Manager:

dotnet add package EightBot.Maui.Badger

Or via the Package Manager Console:

Install-Package EightBot.Maui.Badger

Setup

Add .UseBadger() in your MauiProgram.cs:

using EightBot.Maui.Badger;

public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiApp<App>()
        .UseBadger();  // Add this line

    return builder.Build();
}

Usage

XAML

<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:badger="clr-namespace:EightBot.Maui.Badger;assembly=EightBot.Maui.Badger">
    
    <ContentPage Title="Home"
                 badger:TabBadge.BadgeText="5"
                 badger:TabBadge.BadgeColor="Red"
                 badger:TabBadge.BadgeTextColor="White">
        <!-- Page content -->
    </ContentPage>
    
    <ContentPage Title="Messages"
                 badger:TabBadge.BadgeText="{Binding UnreadCount}"
                 badger:TabBadge.BadgeColor="#FF5722">
        <!-- Page content -->
    </ContentPage>
    
</TabbedPage>

C#

using EightBot.Maui.Badger;

// Set badge on a page
TabBadge.SetBadgeText(myPage, "99+");
TabBadge.SetBadgeColor(myPage, Colors.Red);
TabBadge.SetBadgeTextColor(myPage, Colors.White);

// Clear badge
TabBadge.SetBadgeText(myPage, null);

API Reference

Attached Properties

Property Type Default Description
BadgeText string null The text to display in the badge
BadgeColor Color Colors.Red Badge background color
BadgeTextColor Color Colors.White Badge text color
AutoHide bool true Auto-hide when text is empty or "0"

Sample Application

A sample application demonstrating all features is included in the repository under EightBot.Maui.Badger.Sample.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Badge Notification Library for MAUI applications

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages