-
-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Welcome to SwaggerUI.Themes! This guide will help you integrate beautiful themes into your Swagger UI documentation in seconds.
Choose your package based on your Swagger implementation:
| Implementation | Package Name | NuGet Command |
|---|---|---|
| Swashbuckle | AspNetCore.SwaggerUI.Themes |
dotnet add package AspNetCore.SwaggerUI.Themes |
| NSwag | NSwag.AspNetCore.Themes |
dotnet add package NSwag.AspNetCore.Themes |
Or use the NuGet Package Manager:
# Swashbuckle
Install-Package AspNetCore.SwaggerUI.Themes
# NSwag
Install-Package NSwag.AspNetCore.ThemesAdd a theme to your existing Swagger UI configuration:
using AspNetCore.Swagger.Themes;
// In Program.cs
app.UseSwaggerUI(Theme.Dark);You can still configure Swagger UI options as usual:
app.UseSwaggerUI(Theme.Dark, options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
options.RoutePrefix = string.Empty; // Serve at root
});Unlock additional UI enhancements:
app.UseSwaggerUI(Theme.Dark, options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
// Enable all advanced features
options.EnableAllAdvancedOptions();
// Or enable individually:
// options.EnablePinnableTopbar();
// options.ShowBackToTopButton();
// options.EnableStickyOperations();
// options.EnableExpandOrCollapseAllOperations();
// options.EnableThemeSwitcher();
});See Advanced Options for details on all available features.
Explore built-in themes ready to use. View all themes →
Note
Using InjectStylesheet() could have unintended effects. See Custom Themes for proper custom styling.
Explore the Swashbuckle sample project for a complete working example.
Add a theme to your existing Swagger UI configuration:
using AspNetCore.Swagger.Themes;
// In Program.cs
app.UseSwaggerUi(Theme.Dark);You can still configure NSwag settings as usual:
app.UseSwaggerUi(Theme.Dark, settings =>
{
settings.Path = "/swagger";
settings.DocumentPath = "/swagger/v1/swagger.json";
});Unlock additional UI enhancements:
app.UseSwaggerUi(Theme.Dark, settings =>
{
settings.Path = "/swagger";
// Enable all advanced features
settings.EnableAllAdvancedOptions();
// Or enable individually:
// settings.EnablePinnableTopbar();
// settings.ShowBackToTopButton();
// settings.EnableStickyOperations();
// settings.EnableExpandOrCollapseAllOperations();
// settings.EnableThemeSwitcher();
});See Advanced Options for details on all available features.
Explore built-in themes ready to use. View all themes →
Note
Setting CustomInlineStyles could have unintended effects. See Custom Themes for proper custom styling.
Explore the NSwag sample project for a complete working example.
Styles and JavaScript resources are cached by browsers.
If your theme changes aren't showing:
-
Clear browser cache and reload
-
Clear local storage:
- Open browser DevTools (F12)
- Go to Application/Storage tab
- Clear Local Storage for your site
-
Restart your application to ensure resources are reloaded
Check your configuration:
// ✅ Correct
app.UseSwaggerUI(Theme.Dark, options => ...);If using custom themes, ensure:
- CSS files are set as Embedded Resources
- Files are in the
SwaggerThemesfolder or in the same folder as the custom Theme class - Namespace matches your project structure
Make sure you're enabling them:
// Features must be explicitly enabled
app.UseSwaggerUI(Theme.Dark, options =>
{
options.EnableAllAdvancedOptions(); // All or individual features
});Check browser console (F12) for JavaScript errors.
- Check the Known Issues page for documented limitations
- Check the GitHub issues for similar problems
- Review the Migration Guide if upgrading
- Open a new issue with:
- Your package version
- Framework version (.NET 6/7/8)
- Minimal code example
- Browser console errors (if any)
- Explore All Features - See everything SwaggerUI.Themes can do
- Explore Predefined Themes - See all available themes
- Create Custom Themes - Build your own theme
- Enable Advanced Options - Enhance your UI
- Use CSS Variables - Fine-tune theme colors
using AspNetCore.Swagger.Themes;
app.UseSwaggerUI(Theme.Dark, options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
options.EnableAllAdvancedOptions();
});using AspNetCore.Swagger.Themes;
app.UseSwaggerUi(Theme.Dark, settings =>
{
settings.Path = "/swagger";
settings.EnableAllAdvancedOptions();
});🚀 Getting Started
✨ Features
📖 Migration Guides