Skip to content

Add dark mode support#3091

Open
ega22a wants to merge 3 commits intoorchidsoftware:masterfrom
ega22a:feature/dark-theme
Open

Add dark mode support#3091
ega22a wants to merge 3 commits intoorchidsoftware:masterfrom
ega22a:feature/dark-theme

Conversation

@ega22a
Copy link
Copy Markdown
Contributor

@ega22a ega22a commented Apr 6, 2026

Description

This PR introduces full dark mode support for the Orchid admin panel, built on top of the Bootstrap 5.3 color mode mechanism (data-bs-theme).

Theme Toggle

  • A new Stimulus controller (theme_controller.js) handles toggling between light and dark themes, persisting the user's choice in localStorage.
  • An inline <script> in <head> applies the saved (or OS-preferred) theme before first paint, preventing any flash of unstyled content (FOUC).
  • A sun/moon toggle button is added to the sidebar profile area.

CSS Architecture

  • Introduced --orchid-surface-bg CSS custom property and a .bg-surface utility class as the theme-aware replacement for bg-white across all layout components (cards, tables, modals, filters, metrics, toasts, etc.).
  • Created dark-mode.scss with comprehensive overrides for all Orchid and third-party components: tables, forms, buttons, dropdowns, modals, list groups, CodeMirror, Quill, Flatpickr, Tom Select, Select2, Dropzone, Codeflask, and Leaflet.
  • Replaced hardcoded color values (#fff, $white, $black) with CSS custom properties (var(--bs-body-bg), var(--bs-body-color), var(--bs-tertiary-bg), var(--bs-secondary-bg)) throughout form, reset, layout, and button styles.

SCSS Modernization

  • Migrated all deprecated Sass functions (darken(), lighten(), mix(), fade-out(), saturate()) to their modular equivalents from sass:color (color.adjust(), color.change(), color.mix()).
  • Configured Vite to silence legacy SCSS deprecation warnings during the transition period.

Cleanup

  • Removed hardcoded $modal-content-bg and $popover-bg variables (now handled by Bootstrap's built-in dark mode).
image

ega22a added 3 commits April 6, 2026 21:52
Added the `css.preprocessorOptions.scss.silenceDeprecations` section to suppress warnings about deprecated Sass functions (`import`, `global-builtin`, `color-functions`, `if-function`).
The `publicDir` setting has been disabled.
…module

The outdated functions `darken()`, `lighten()`, `mix()`, `fade-out()`, and `saturate()` have been replaced with their modular equivalents `color.adjust()`, `color.change()`, and `color.mix()` from `sass:color`.
Dark theme support based on Bootstrap 5.3's `data-bs-theme` has been implemented:

- A Stimulus controller named `theme` has been added to toggle and save the theme to localStorage
- An inline script in <head> prevents flickering (FOUC) during loading
- Theme toggle button (sun/moon) in the sidebar profile
- Introduced the CSS variable --orchid-surface-bg and the utility class .bg-surface
- Replaced hard-coded bg-white, $white, $black with CSS variables (var(--bs-body-bg), var(--bs-body-color), var(--bs-tertiary-bg), var(--bs-secondary-bg))
- Added the dark-mode.scss file with overrides for all Orchid components (tables, forms, buttons, modals, dropdowns, CodeMirror, Quill, Flatpickr, Tom Select, Select2, Dropzone, etc.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant