Skip to content

✨ Customize and switch dynamic themes for your Swagger API documentation instantly

License

Notifications You must be signed in to change notification settings

teociaps/SwaggerUI.Themes

SwaggerUI.Themes Logo

SwaggerUI.Themes

Build Tests

Give your ASP.NET Core API documentation the look it deserves!

Switch themes at runtime  •  Unlock new capabilities  •  Create and choose your custom style
...and more!

Get StartedView Built-in ThemesFull Documentation

SwaggerUI.Themes Demo

Note: GIF framerate is limited. Actual transitions are buttery smooth!


Package Purpose NuGet
AspNetCore.SwaggerUI.Themes For Swashbuckle.AspNetCore swashbuckle-nuget
NSwag.AspNetCore.Themes For NSwag.AspNetCore nswag-nuget

Warning

Version 3.x Breaking Changes

Upgrading from v2.x? Please review the Migration Guide for important API changes.

🚀 Quick Start

# Install package
dotnet add package AspNetCore.SwaggerUI.Themes
# or
dotnet add package NSwag.AspNetCore.Themes
// Apply a theme - that's it!
app.UseSwaggerUI(Theme.Dark);      // Swashbuckle
// or
app.UseSwaggerUi(Theme.Dark);      // NSwag

// Enable runtime theme switcher!
app.UseSwaggerUI(Theme.Dark, c => c.EnableThemeSwitcher());

✨ Features

  • 🔥 Theme Switcher - Switch built-in and custom themes dynamically without page reload

  • Built-in Themes - Choose from predefined themes ready to use

  • Custom Themes - Build your own themes with full control, or create standalone themes with zero dependencies

  • Advanced Features - Enhance your documentation with powerful UI capabilities

  • ...discover more in the Wiki!

📚 Basic Usage Examples

Swashbuckle

using AspNetCore.Swagger.Themes;

...

// Simple theme
app.UseSwaggerUI(Theme.Dark);

// With runtime theme switcher
app.UseSwaggerUI(Theme.Dark, c =>
{
    c.EnableThemeSwitcher(); // Auto-discovers all custom themes!
});

// All advanced features
app.UseSwaggerUI(Theme.Dark, c =>
{
    c.EnableAllAdvancedOptions();
});

...

NSwag

using AspNetCore.Swagger.Themes;

...

// Simple theme
app.UseSwaggerUi(Theme.Dark);

// With runtime theme switcher
app.UseSwaggerUi(Theme.Dark, c =>
{
    c.EnableThemeSwitcher(); // Auto-discovers all custom themes!
});

// All advanced features
app.UseSwaggerUi(Theme.Dark, c =>
{
    c.EnableAllAdvancedOptions();
});

...

💡 Build your own Custom Theme

// Organize themes in folders
// SwaggerThemes/Brands/mybrand.css

public class MyBrandTheme : Theme
{
    protected MyBrandTheme(string fileName) : base(fileName) { }
    public static MyBrandTheme Custom => new("mybrand.css");
    //... and others!
}

// Usage
app.UseSwaggerUI(MyBrandTheme.Custom, c =>
{
    c.EnableThemeSwitcher(); // Works with custom themes too!
});

Learn advanced usages in the Wiki!

🤝 Contributing

Contributions are welcome! See the Contributing Guide for details.

📜 License

MIT Licensed - see LICENSE for details.


Made with ❤️ by @teociaps

About

✨ Customize and switch dynamic themes for your Swagger API documentation instantly

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 2

  •  
  •