question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Color schemes: allow user to choose/toggle schemes

See original GitHub issue

I checked that…

  • … the documentation does not mention anything about my idea
  • … to my best knowledge, my idea wouldn’t break something for other users
  • … there are no open or closed issues that are related to my idea

Description

As of #1639 a dark palette scheme (slate) was added. Discussions regarding adding a toggle for this have been discussed #1639 comments, #1716 comments, and #1266. This issue can capture these discussions. To keep this generalized, I will give my thoughts for potential solution in a comment.

Use Cases

While supporting different themes / schemes and defaulting based upon prefers-color-scheme are phenomenal, adding a toggle would directly allow each user to manually set the theme according to their preferences.

Screenshots / Mockups

n/a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:29 (21 by maintainers)

github_iconTop GitHub Comments

3reactions
squidfunkcommented, Aug 23, 2020

Thanks for sharing your implementation! I’m planning to put it in the table of contents, as I’m thinking about moving some more stuff there like “Edit this page” and maybe a Print button, so like a context menu, which is why we need more space than just the icon. Also, maybe later, a language switch could land there. Let’s see how that works out.

2reactions
squidfunkcommented, Aug 16, 2020

I’ve started working on the theme toggle. As proposed in this issue, it’s possible to provide 2 or more alternate themes from which the user can choose. The chosen theme is persisted across requests and does not induce flickering upon page load. The author can specify an icon and a label for the theme:

theme:
  palette:
    - scheme: default
      primary: indigo
      accent: indigo
      toggle:
        name: Switch to light mode
        icon: material/weather-sunny
    - scheme: slate
      primary: pink
      accent: pink
      toggle:
        name: Switch to dark mode
        icon: material/weather-night

This is the current concept – it always sticks to the lower right corner:

screenshot-localhost-8000-setup-adding-a-git-repository-1597598455997

Positioning might change, as I’m still experimenting. This is how it looks in action (click on the image, if it doesn’t auto-play):

Ohne Titel 2

This feature will be released in Material for MkDocs Insiders as part of the Black Pearl Funding goal. It will first be exclusively available to sponsors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a Color Scheme Toggle - ryanfiller.com
This post by Andy Bell (who for some reason goes by Hank Chizljaw sometimes) puts together a pretty clever way to handle user...
Read more >
Themed websites with multiple color schemes the easy way
In this blog post I'm going to explain you how to apply and switch color schemes (themes) in a web application. I find...
Read more >
Switch Between Color Schemes with CSS Variables and ...
In this tutorial, we'll discuss how to implement different color schemes on a website using CSS variables and one line of vanilla JavaScript. ......
Read more >
color-scheme - CSS: Cascading Style Sheets - MDN Web Docs
The color-scheme CSS property allows an element to indicate which color schemes it can comfortably be rendered in.
Read more >
Dark mode toggle - Jouni Kantola. Web developer.
How do you persist the user's choice? How do you reactivate the user's preference on return? Automagic toggle. Lately color schemes, especially ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found