[Feature Request]: Add option to assume default light/dark preference from user system preferences #2579

Open
opened 2026-02-05 04:33:19 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @xplosionmind on GitHub (Jan 17, 2022).

Describe the feature you'd like

It would be great if light and dark mode could be toggle automatically, according to the OS preference the user is visiting from.

Describe the benefits this feature would bring to BookStack users

No need to manually toggle dark or light theme every time

Additional context

No response

Originally created by @xplosionmind on GitHub (Jan 17, 2022). ### Describe the feature you'd like It would be great if light and dark mode could be toggle automatically, according to the OS preference the user is visiting from. ### Describe the benefits this feature would bring to BookStack users No need to manually toggle dark or light theme every time ### Additional context _No response_
OVERLORD added the 🔨 Feature Request label 2026-02-05 04:33:19 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jan 17, 2022):

Thanks for the suggestion @xplosionmind.

No need to manually toggle dark or light theme every time

The light/dark preference will be stored against the session of the visitor of against the user account if logged in, hence should already not need setting on every visit although sessions may expire.

I guess we could add an auto value to this env option but we'd need have to handle the value on the PHP side, to then run some JS which would sniff CSS to detect this. Not ideal since pretty messy.

@ssddanbrown commented on GitHub (Jan 17, 2022): Thanks for the suggestion @xplosionmind. > No need to manually toggle dark or light theme every time The light/dark preference will be stored against the session of the visitor of against the user account if logged in, hence should already not need setting on every visit although sessions may expire. I guess we could add an `auto` value to [this env option](https://github.com/BookStackApp/BookStack/blob/2aace1670478b8f2c25cbd95bb4edba004e8ccbb/.env.example.complete#L279-L281) but we'd need have to handle the value on the PHP side, to then run some JS which would sniff CSS to detect this. Not ideal since pretty messy.
Author
Owner

@boscorelly commented on GitHub (Jan 29, 2025):

Maybe integrate the window.matchMedia API ?

@boscorelly commented on GitHub (Jan 29, 2025): Maybe integrate the window.matchMedia API ?
Author
Owner

@Bert-Proesmans commented on GitHub (Feb 3, 2025):

The light/dark preference will be stored against the session of the visitor of against the user account if logged in, hence should already not need setting on every visit although sessions may expire.

I guess we could add an auto value to this env option but we'd need have to handle the value on the PHP side, to then run some JS which would sniff CSS to detect this. Not ideal since pretty messy.

or approach the other way around;

  • The session stored preference becomes a tri-state; unset/light/dark
    • unset: the frontend (by default) follows the browser preference, like boscorelly also mentions
    • dark: activates dark mode
    • light: activates light mode
  • The env variable APP_DEFAULT_DARK_MODE becomes a tri-state:
    • unset: leave session value unset at creation + show light/dark mode toggle => session value is set after user toggles
    • dark: always dark (aka force session value at all time) + disable toggle
    • light: always light (aka force session value at all time) + disable toggle

I can imagine the environment variable APP_DEFAULT_DARK_MODE was introduced as a solution to some related but different problem. Users that want to explicitly set their color mode from the application are very likely in the single digit percentages. Apps following the browser preference for color scheme is the sane default that users come to expect since a couple (5) of years.

@Bert-Proesmans commented on GitHub (Feb 3, 2025): > The light/dark preference will be stored against the session of the visitor of against the user account if logged in, hence should already not need setting on every visit although sessions may expire. > > I guess we could add an `auto` value to [this env option](https://github.com/BookStackApp/BookStack/blob/2aace1670478b8f2c25cbd95bb4edba004e8ccbb/.env.example.complete#L279-L281) but we'd need have to handle the value on the PHP side, to then run some JS which would sniff CSS to detect this. Not ideal since pretty messy. or approach the other way around; * The session stored preference becomes a tri-state; unset/light/dark * unset: the frontend (by default) follows the [browser preference](https://stackoverflow.com/a/52986538), like boscorelly also mentions * dark: activates dark mode * light: activates light mode * The env variable APP_DEFAULT_DARK_MODE becomes a tri-state: * unset: leave session value unset at creation + show light/dark mode toggle => session value is set after user toggles * dark: always dark (aka force session value at all time) + disable toggle * light: always light (aka force session value at all time) + disable toggle I can imagine the environment variable APP_DEFAULT_DARK_MODE was introduced as a solution to some related but different problem. Users that want to explicitly set their color mode from the application are very likely in the single digit percentages. Apps following the browser preference for color scheme is the sane default that users come to expect since a couple (5) of years.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2579