Skip to content

Can't get dark mode to work with Swagger #1484

Description

@ian-twilightcoder

I'm using the latest drf-spectacular-sidecar which has Swagger 5.31 with dark mode support. However, I can't figure out how to get the dark mode toggle on my API page. I tried using the standalone preset:

SPECTACULAR_SETTINGS = {
    'SWAGGER_UI_SETTINGS': {
        'presets': ['SwaggerUI.presets.ApisPreset', 'SwaggerUIStandalonePreset'],
    },
}

But that just made my page not render at all. Do I need to do something on my SpectacularSwaggerView? I tried adding 'SwaggerUIStandalonePreset' to SwaggerUIBundle(...presets...) in drf_spectacular/swagger_ui.js but that didn't make a difference. If I add class="dark mode" to the tag in drf_spectacular/swagger_ui.html then that works, but then it's just stuck in dark mode without a toggle.

Has anyone gotten dark mode to work with drf-spectacular-sidecar?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions