BadgeGenerator 2.0.1

dotnet add package BadgeGenerator --version 2.0.1                
NuGet\Install-Package BadgeGenerator -Version 2.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BadgeGenerator" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BadgeGenerator --version 2.0.1                
#r "nuget: BadgeGenerator, 2.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BadgeGenerator as a Cake Addin
#addin nuget:?package=BadgeGenerator&version=2.0.1

// Install BadgeGenerator as a Cake Tool
#tool nuget:?package=BadgeGenerator&version=2.0.1                

BadgeGenerator

Provides possibility of programmatically generating SVG badges.

Installation

dotnet add package BadgeGenerator

Usage

using BadgeGenerator;

List<BadgeSection> badgeSections = new()
{
    new()
    {
        Content = new Uri("https://example.com/healthy.png"),
        IconSize = 12,
        BackgroundColor = "#555"
    },
    new()
    {
        Content = "Status",
        ForegroundColor = "#fff",
        BackgroundColor = "#555"
    },
    new()
    {
        Content = "Healthy",
        ForegroundColor = "#fff",
        BackgroundColor = "rgb(11, 97, 42)"
    }
};

var badgeSvg = BadgeCreator.CreateBadgeSvg(badgeSections, new BadgeMetadata { Height = 20, Padding = 10 });
Console.WriteLine(badgeSvg);

This will output the SVG of the badge with three sections: one with a healthy.png icon, another with the text "Status" and the third one with text "Healthy". You can customize the badge's size and padding by passing a BadgeMetadata object:

var metadata = new BadgeMetadata
{
    Height = 28,
    Padding = 12
};

Contributing

Read more about this project on the Github repository page.

License

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

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BadgeGenerator:

Package Downloads
BadgeGenerator.AspNetCore.HealthChecks.Badge

Adds middleware that can return different badges indicating the current health of a web application.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 89 11/15/2024
1.0.0 291 9/29/2024