-
-
Notifications
You must be signed in to change notification settings - Fork 1
Features
Discover everything SwaggerUI.Themes can do to transform your Swagger UI documentation. From beautiful themes to powerful UI enhancements and fine-grained customization—all designed to work together seamlessly.
SwaggerUI.Themes provides three main categories of features to enhance your API documentation:
| Category | What It Enables | Quick Start |
|---|---|---|
| 🎨 Theming | Beautiful visual designs and custom branding | Apply a predefined theme or create your own |
| ⚡ UI Enhancements | Interactive features for better navigation | Enable advanced options with one line |
| 🔧 Customization | Fine-tune colors and icons | Override CSS variables |
Transform the look and feel of your Swagger UI with professionally designed themes or create your own custom designs.
Six ready-to-use themes that work out of the box:
| Theme | Description | Best For | Preview |
|---|---|---|---|
| Dark | Dark theme with blue accents and high contrast | Night-time development, reduced eye strain | View → |
| Light | Clean, bright theme with subtle colors | Daytime use, presentations | View → |
| Forest | Nature-inspired green tones | Environmental/eco-friendly APIs | View → |
| DeepSea | Deep ocean blue palette | Data/analytics platforms | View → |
| Desert | Warm desert sand colors | Creative/design APIs | View → |
| Futuristic | Vibrant neon colors with tech aesthetic | Modern/cutting-edge projects | View → |
Quick Example:
app.UseSwaggerUI(Theme.Dark);📖 Learn more about Predefined Themes →
Create your own unique themes with four different approaches (from most to least powerful):
| Method | Best For | Features |
|---|---|---|
| Theme Classes ⭐ | Production custom themes | Type-safe, auto-discovery |
| Embedded Files | Custom branded themes | CSS variables, organized code |
| Standalone Themes | Unique, from-scratch designs | Complete independence |
| Inline CSS | Quick tweaks, prototyping | Basic styling, rapid testing |
📖 Learn more about Custom Themes →
Unlock powerful interactive features that improve navigation and user experience:
| Feature | Description | Enable Method |
|---|---|---|
| Dynamic Theme Switcher 🔥 | Allow users to switch between themes at runtime with auto-discovery | EnableThemeSwitcher() |
| Sticky Operations | Keeps operation summary visible while scrolling through long parameter lists | EnableStickyOperations() |
| Pinnable Topbar | Pin the navigation bar to stay visible while scrolling | EnablePinnableTopbar() |
| Back to Top | Quick scroll-to-top button for easy navigation | ShowBackToTopButton() |
| Expand/Collapse All | Bulk controls to expand or collapse all operations at once | EnableExpandOrCollapseAllOperations() |
Enable all advanced features with a single method:
app.UseSwaggerUI(Theme.Dark, options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
options.EnableAllAdvancedOptions(); // Includes theme switcher
});Or enable specific features as needed:
app.UseSwaggerUI(Theme.Dark, options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
// Enable only the features you want
options.EnableThemeSwitcher();
options.EnablePinnableTopbar();
options.ShowBackToTopButton();
options.EnableStickyOperations();
options.EnableExpandOrCollapseAllOperations();
});📖 Learn more about Advanced Options →
Fine-tune your theme's appearance using CSS variables for precise control over colors, icons, and more.
Override specific CSS variables to customize any theme:
:root {
--topbar-background: #1a1a2e;
--topbar-text-color: #eaeaea;
--operation-get-background: #28a745;
--operation-post-background: #007bff;
}📖 View complete CSS Variables Reference →
All features work together seamlessly. Here are common combinations:
app.UseSwaggerUI(Theme.Dark, options =>
{
options.EnableAllAdvancedOptions();
});app.UseSwaggerUI(CustomTheme.MyTheme, options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
options.EnablePinnableTopbar();
options.ShowBackToTopButton();
});app.UseSwaggerUI(CustomTheme.Brand, options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
options.DocumentTitle = "My Company API Documentation";
options.RoutePrefix = string.Empty;
// All advanced features
options.EnableAllAdvancedOptions();
});Understanding which features work together:
| Feature Category | Works With Predefined Themes | Works With Custom Themes | Works With Standalone Themes | Works With CSS Variables |
|---|---|---|---|---|
| Dynamic Theme Switcher | ✅ Yes | ✅ Yes | ❌ No³ | ✅ Yes |
| Custom Themes (Inline/Embedded/Classes) | ❌ No¹ | ✅ Yes | ❌ No¹ | ✅ Yes |
| Predefined Themes | N/A | ❌ No¹ | ❌ No¹ | ✅ Yes |
| Standalone Themes | ❌ No¹ | ❌ No¹ | N/A | |
| UI Enhancements | ✅ Yes | ✅ Yes | ❌ No³ | ✅ Yes |
| CSS Variables | ✅ Yes | ✅ Yes | N/A |
Notes:
- Only one theme method can be active at a time. Choose either predefined, custom, or standalone.
- Standalone themes require manual integration of variables and features.
- UI enhancements and theme switcher require JavaScript, which standalone themes don't include by default.
✅ Best Practices:
- Predefined theme + UI enhancements + CSS variable overrides
- Custom theme (Embedded/Classes) + UI enhancements + CSS variables + theme switcher
- Inline CSS for quick prototyping, then migrate to Embedded Files for production
❌ Avoid:
- Using
InjectStylesheet()to override theme CSS (breaks theming system) - Standalone themes with UI enhancements or theme switcher (features won't work)
Choose your path based on what you want to accomplish:
...apply a theme quickly
- Choose a predefined theme
- Follow the Getting Started guide
- Apply it:
app.UseSwaggerUI(Theme.Dark);
...create a branded theme
- Review Custom Themes overview
- Choose the Embedded Files method or Theme Classes method
- Check the CSS Variables reference
...add interactive features
- Pick your theme (predefined or custom)
- Review Advanced Options
- Enable with
options.EnableAllAdvancedOptions()
...fine-tune colors and spacing
- Start with a base theme
- Check CSS Variables reference
- Override specific variables in your CSS
...build something completely custom
- Review the Standalone Themes method
- Study the CSS Variables structure
- Build from scratch with complete freedom
- Questions? Check the Getting Started guide
- Found a bug? Report it on GitHub
- Feature ideas? We'd love to hear them!
- Examples? Explore the sample projects
Happy theming! 🎨
🚀 Getting Started
✨ Features
📖 Migration Guides