Skip to content

feat(ui): add dark mode that follows the system color scheme - #1964

Draft
anton264 wants to merge 3 commits into
LibreBooking:mainfrom
anton264:feature/dark-mode
Draft

anton264 wants to merge 3 commits into
LibreBooking:mainfrom
anton264:feature/dark-mode

Conversation

@anton264

@anton264 anton264 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a dark mode. By default it follows the browser/OS color scheme and switches live when that changes (no reload needed). Users can also pick Light, Dark or Auto from a menu in the navigation bar.

  • New setting css.color.mode (LB_CSS_COLOR_MODE): auto (default), light, or dark. It sets the default mode. Unknown values fall back to auto.
  • A color mode menu in the navigation bar (Light / Dark / Auto) lets each user override the default. The choice is stored per browser in local storage, so it also works on pages before login. It is not tied to the user account. Other open tabs pick up a change.
  • Web/scripts/color-mode.js is loaded in <head> before any CSS. It sets Bootstrap 5.3's data-bs-theme on <html> so pages don't flash light first, and listens for prefers-color-scheme changes.
  • Adds [data-bs-theme='dark'] overrides for LibreBooking's hard-coded light colors: page background, schedule grid and labels, dashboard, dialogs, jqtree, flatpickr, FullCalendar, select2 and Trumbowyg.
  • Bootstrap tooltips (including the reservation popups) use a dark surface in dark mode. Bootstrap 5.3 shows them white by default, which did not match the browser's native tooltips.
  • Accent-colored text (links, outline buttons, accordion headers) uses a new --primary-text variable, which is lightened in dark mode so the dark accent themes stay readable. Button backgrounds keep the original accent color.
  • Templates use bg-body / bg-body-tertiary instead of bg-white / bg-light so they adapt. The resource QR code stays on white so it still scans.
  • Reservation slot colors are unchanged, since admins can customize them.
  • Light mode is visually unchanged.
  • Translations for the new menu are added for da, de, es, fi, fr, it, ja, nl, pl, pt-BR, pt-PT, ru and sv. Other languages fall back to English.

Breaking change

The accent theme (css.theme) was stored in data-bs-theme on <body>. That attribute belongs to Bootstrap's color mode, so Bootstrap's dark mode could never apply. The accent theme now uses data-lb-theme.

Custom CSS loaded via css.extension.file that targets [data-bs-theme='<theme>'] must switch to [data-lb-theme='<theme>']. This is documented in BASIC-CONFIGURATION.rst and marked with a BREAKING CHANGE: footer, so it will trigger a major release. If maintainers would rather avoid a major bump for this, I can look into a compatibility approach.

Testing

  • New data-provider tests for Page::normalizeColorMode() in tests/Pages/PageTest.php.
  • composer phpcsfixer:lint, PHPStan, config-dist:check, env-example:check, and npm run lint:frontend all pass.
  • The full PHPUnit suite has the same results as main.
  • Manually checked in the e2e Docker stack (tests/e2e/docker) with Playwright, with the color scheme emulated as dark and light:
    • Dashboard and schedule render correctly in both modes.
    • With Auto, switching the emulated scheme at runtime flips the page without a reload.
    • Choosing Light or Dark in the menu applies right away, survives a reload, and ignores the OS setting. The menu marks the active choice.
    • Reservation popups on the dashboard and schedule have the same dark background.

Docs

docs/source/BASIC-CONFIGURATION.rst documents css.color.mode, the color mode menu, and the data-lb-theme selector. config/config.dist.php and .env.example are regenerated.

🤖 Generated with Claude Code

schedule-dark dashboard-dark

@labmecanicatec

Copy link
Copy Markdown
Contributor

Great work! This PR goes a long way toward enabling a potential migration to Bootstrap 6. I just have two observations:

Theme selector: It would be worth adding a button that lets the user toggle between dark and light themes (and vice versa), so the switch doesn't rely solely on the system preference.

Tooltips in dark mode: I noticed an inconsistency in dark mode: the Dashboard tooltips have a light background, while the Schedule ones have a dark background. It would be good to unify the styling of both components to keep the visuals consistent.

Thanks for the effort—everything else looks great.

Anton added 3 commits November 19, 2026 05:47
Add a css.color.mode setting (auto, light, dark; default auto). In
auto mode an inline script in the page head sets Bootstrap's
data-bs-theme on <html> from prefers-color-scheme before any CSS
loads, and updates it live when the OS or browser setting changes.

The accent theme (css.theme) was stored in data-bs-theme on <body>,
which prevented Bootstrap's dark mode from ever applying. It now
uses a separate data-lb-theme attribute.

Dark overrides cover LibreBooking's hard-coded light colors: page
background, schedule grid and labels, dashboard, dialogs, jqtree,
flatpickr, FullCalendar, select2 and Trumbowyg. Accent-colored text
uses a new --primary-text variable that is lightened in dark mode
for contrast. Templates use bg-body / bg-body-tertiary instead of
bg-white / bg-light so they adapt; the resource QR code stays white.
Light mode is visually unchanged.

BREAKING CHANGE: The accent theme attribute on <body> is renamed
from data-bs-theme to data-lb-theme. Custom CSS (css.extension.file)
that targets [data-bs-theme='<theme>'] must use
[data-lb-theme='<theme>'] instead.

Assisted-by: Claude:claude-opus-5-5
Bootstrap 5.3 inverts tooltips in dark mode, so reservation popups and
other Bootstrap tooltips were white, while native title tooltips, such
as those on the schedule toolbar icons, were dark. Give Bootstrap
tooltips a raised dark surface with a border so all tooltips look the
same in dark mode.

Assisted-by: Claude:claude-opus-5-5
Add a color mode menu to the navigation bar with Light, Dark and Auto
options, so users are not limited to the system preference. The
choice is stored per browser in local storage and overrides the
css.color.mode setting, which now sets the default mode. Other open
tabs pick up a change made in one tab.

Move the color mode script from an inline block in globalheader.tpl
to Web/scripts/color-mode.js. It is still loaded before any CSS, so
pages do not flash light first.

Assisted-by: Claude:claude-opus-5-5
@anton264

anton264 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Both points are addressed:

Theme selector: There is now a color mode menu in the navigation bar with Light, Dark and Auto. The choice is saved per browser and overrides the css.color.mode default. Auto keeps following the system setting.

Tooltips: Bootstrap 5.3 shows its tooltips white in dark mode, while the browser's native tooltips (for example on the schedule toolbar icons) are dark. Bootstrap tooltips, including the reservation popups on the dashboard and schedule, now use a dark background in dark mode, so they all match. If you saw the difference on a different element, let me know which one and I'll look at it.

I also rebased the branch on the latest main.

image

@labmecanicatec

Copy link
Copy Markdown
Contributor

Thanks for the work on the light/dark theme. It works well, but please keep in mind that the changes made here to the .tpl files will not apply once #1860 (the migration from Smarty to Twig) is active, as the engine will select the corresponding .twig file if it exists.

Therefore, you will need to ensure that these changes are replicated in the .twig templates when they are integrated, or re-apply them directly to those files if #1860 has already been merged into the target branch.

Look #1860

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants