Skip to content

Add a light/dark/auto theme selector to the create-app layout#15941

Open
codeconsole wants to merge 2 commits into
apache:8.0.xfrom
codeconsole:feat/create-app-theme-selector
Open

Add a light/dark/auto theme selector to the create-app layout#15941
codeconsole wants to merge 2 commits into
apache:8.0.xfrom
codeconsole:feat/create-app-theme-selector

Conversation

@codeconsole

Copy link
Copy Markdown
Contributor

Summary

Adds a Bootstrap 5.3 color-mode (light / dark / auto) switcher to the default generated application, so a freshly created app can toggle and remember its theme out of the box. The generated layout already uses theme-aware Bootstrap utilities and grails.css already has [data-bs-theme=dark] rules — this wires up the missing UI + persistence.

Independent of, and additive to, the i18n language-selector PR (#15940); both live in the same navbar but neither depends on the other.

Changes

New theme.js asset (clean-room, ASF-licensed — not a copy of Bootstrap's CC-BY docs snippet)

  • Persists the choice in localStorage; toggles data-bs-theme on <html>; auto follows the OS via prefers-color-scheme and re-resolves on OS change.
  • Applied immediately on load and wired to the buttons on DOMContentLoaded (updates the active check + toggle icon).

Default layout (grails-forge template + classic web profile skeleton)

  • Loads theme.js in the <head> so the theme is set before the page paints (no flash of the wrong theme).
  • Adds a light/dark/auto dropdown to the navbar (Bootstrap Icons, already a dependency).

grails-forge AssetPipeline feature

  • Registers theme.js so it is copied into the generated app's grails-app/assets/javascripts/.

Tests

  • GrailsGspSpec gains a check that a generated WEB app ships theme.js, loads it in the head, and that the navbar offers the light/dark/auto options.

All green.

Add a Bootstrap 5.3 color-mode switcher to the default generated
application. A new theme.js asset persists the choice in localStorage and
toggles data-bs-theme on the document element ("auto" follows the
operating system); it is loaded in the document head so the theme is
applied before the page paints, avoiding a flash of the wrong theme. A
light/dark/auto dropdown is added to the navbar of both the grails-forge
template and the classic web profile skeleton, and theme.js is registered
as a generated asset in the grails-forge AssetPipeline feature.
@testlens-app

This comment has been minimized.

The "Installed plugins" table header used the fixed `table-light` class,
which stayed light in dark mode and left the header illegible. Bootstrap
table cells paint their own background from `--bs-table-bg`, so a utility
such as `bg-body-tertiary` on the thead is covered and shows no color;
instead set `--bs-table-bg` to the theme-adaptive `--bs-tertiary-bg`. The
header now follows the active light/dark color mode and matches the page's
other tertiary surfaces, in both the grails-forge template and the classic
web profile skeleton.
@codeconsole codeconsole force-pushed the feat/create-app-theme-selector branch from 4772dcf to f9ca048 Compare July 8, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant