Switch themes at runtime • Unlock new capabilities • Create and choose your custom style
...and more!
Get Started • View Built-in Themes • Full Documentation
Note: GIF framerate is limited. Actual transitions are buttery smooth!
| Package | Purpose | NuGet |
|---|---|---|
| AspNetCore.SwaggerUI.Themes | For Swashbuckle.AspNetCore | |
| NSwag.AspNetCore.Themes | For NSwag.AspNetCore |
Warning
Version 3.x Breaking Changes
Upgrading from v2.x? Please review the Migration Guide for important API changes.
# 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());-
🔥 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!
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();
});
...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();
});
...// 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!
Contributions are welcome! See the Contributing Guide for details.
MIT Licensed - see LICENSE for details.
Made with ❤️ by @teociaps