Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Images for light and dark theme #9386

Open
okvalsralos opened this issue Nov 6, 2023 · 6 comments
Open

[Feature Request] Images for light and dark theme #9386

okvalsralos opened this issue Nov 6, 2023 · 6 comments
Labels
markdown Authoring and presenting content using markdown

Comments

@okvalsralos
Copy link

okvalsralos commented Nov 6, 2023

Describe the solution you'd like
docfx has a switcher in the header that lets readers choose between the light and the dark theme. If applicable authors should provide both the light and the dark version of every screenshot used in the documentation.

Additional context
Add the _dark.png suffix to the name of the dark image version. This image will be then used when the user switches to the dark theme.

For example, save images as example.png and example_dark.png.

@yufeih yufeih added the markdown Authoring and presenting content using markdown label Nov 7, 2023
@BarkenBark
Copy link

+1

1 similar comment
@CaseyHofland
Copy link

+1

@bitbonk
Copy link
Contributor

bitbonk commented Feb 2, 2024

Until this feature is implemented, do you known of any trick or workaround how to provide different images (and some icons) based on the theme?

@zhaparoff
Copy link

Or at least set light theme as default and disable theme switcher without deep diving into custom template creation...

@ghost
Copy link

ghost commented Jul 28, 2024

It depends on the logo, but it's possible to create a transparent background logo which will work in light and dark themes.

@bouda19
Copy link

bouda19 commented Aug 13, 2024

@bitbonk

You can achieve that by adding a custom template and a main.css file with the following content :

#logo {
    margin-right: 10px;
}

[data-bs-theme=dark] #logo {
    content:url("../images/dark-logo.png");
}

[data-bs-theme=light] #logo {
    content:url("../images/light-logo.png");
}

I have created a sample repo and a sample demo site if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
markdown Authoring and presenting content using markdown
Projects
None yet
Development

No branches or pull requests

7 participants