Skip to content

[BootstrapAdminUi] Add an auto mode to the theme switcher - #407

Merged
loic425 merged 1 commit into
Sylius:mainfrom
loic425:feat/admin-theme-auto-mode
Nov 13, 2026
Merged

loic425 merged 1 commit into
Sylius:mainfrom
loic425:feat/admin-theme-auto-mode

Conversation

@loic425

@loic425 loic425 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member
Q A
Branch? main
Bug fix? no
New feature? yes
BC breaks? no
License MIT

The admin theme switcher only toggles between light and dark. Once you click it, your OS preference is ignored for good, and there is no way to go back to following it.

The button now opens a dropdown with three options:

  • Light and Dark force the theme, as before.
  • Auto follows prefers-color-scheme, and updates live when the OS switches (e.g. at sunset), across open tabs too.
  • The button shows the icon of the selected mode (sun, moon or screen), and the active option is highlighted.

Auto is the default and is stored by removing the sylius-theme key, so admins who never picked a theme get the same behaviour as today, and those who did keep their choice. The toggle action is kept for templates that still use it.

Translations were added in en, fr, de, es, nl and pl. public/ assets were rebuilt with yarn build.

Light Dark
Theme switcher with Light selected Theme switcher with Dark selected
Auto (OS light) Auto (OS dark)
Theme switcher with Auto selected and a light OS Theme switcher with Auto selected and a dark OS

@loic425
loic425 force-pushed the feat/admin-theme-auto-mode branch from 60b8728 to 60b2ec5 Compare November 13, 2026 09:15
TheMilek added a commit to Sylius/Sylius that referenced this pull request Nov 13, 2026
| Q               | A
|-----------------|-----
| Branch?         | 2.4
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | port of Sylius/Stack#407
| License         | MIT

The admin theme switcher only toggles between light and dark. Once you
click it, your OS preference is ignored for good, and there is no way to
go back to following it.

The button now opens a dropdown with three options:

- **Light** and **Dark** force the theme, as before.
- **Auto** follows `prefers-color-scheme`, and updates live when the OS
switches (e.g. at sunset), across open tabs too.
- The button shows the icon of the selected mode (sun, moon or screen),
and the active option is highlighted.

Auto is the default and is stored by removing the `sylius-admin-theme`
key, so admins who never picked a theme get the same behaviour as today,
and those who did keep their choice. The `toggle` action is kept for
templates that still use it.

The new labels (`theme_auto`, `theme_dark`, `theme_light`) and the
existing `toggle_theme`, which was only in English, are translated in
all 51 admin locales.

| Light | Dark |
|-------|------|
| <img width="400" alt="Theme switcher with Light selected"
src="https://github.com/user-attachments/assets/2ed240ab-34cc-4345-a613-2d3f25c0314d"
/> | <img width="400" alt="Theme switcher with Dark selected"
src="https://github.com/user-attachments/assets/65b89f47-54c7-411c-a6e1-743e12b41b8e"
/> |

| Auto (OS light) | Auto (OS dark) |
|-----------------|----------------|
| <img width="400" alt="Theme switcher with Auto selected and a light
OS"
src="https://github.com/user-attachments/assets/d7175193-0cfb-42b3-a2fd-18799ec65378"
/> | <img width="400" alt="Theme switcher with Auto selected and a dark
OS"
src="https://github.com/user-attachments/assets/39d4551a-9f25-42bf-9b7b-d900db8b9861"
/> |
@loic425
loic425 merged commit 0358a2d into Sylius:main Nov 13, 2026
6 checks passed
@loic425
loic425 deleted the feat/admin-theme-auto-mode branch November 13, 2026 14:15
loic425 added a commit that referenced this pull request Nov 18, 2026
Port of the BootstrapAdminUi auto mode (#407): the switcher opens a
Light / Dark / Auto menu, Auto follows prefers-color-scheme live and
across tabs, and is the default (no stored sylius-theme key).
loic425 added a commit that referenced this pull request Nov 18, 2026
| Q               | A
|-----------------|-----
| Branch?         | shadcn-admin-ui
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Related tickets | port of #407
| License         | MIT

The BootstrapAdminUi theme switcher got an auto mode in #407, but the
ShadcnAdminUi one still only toggles between light and dark: once
clicked, the OS preference is ignored for good.

The button now opens a shadcn `DropdownMenu` with three radio items:

- **Light** and **Dark** force the theme, as before.
- **Auto** follows `prefers-color-scheme`, live when the OS switches and
across open tabs.
- The button shows the icon of the selected mode (sun, moon or monitor),
and the selected item is checked.

Same storage as Bootstrap: Auto is the default and removes the
`sylius-theme` key, so admins who never picked a theme see no change and
those who did keep their choice. The inline script sets
`data-theme-mode` on `<html>` before the stylesheet, so there is no
flash and the right icon shows before Stimulus connects. The `toggle`
action is kept for overridden templates.

Labels reuse the `sylius.ui.theme_*` keys added to UiTranslations in
#407. `lucide:monitor` was added to the test app's locked icons.

| Light | Dark |
|-------|------|
| <img width="400" alt="Theme switcher with Light selected"
src="https://github.com/user-attachments/assets/e82a8b88-a590-40db-b821-fb4083dbf8d9"
/> | <img width="400" alt="Theme switcher with Dark selected"
src="https://github.com/user-attachments/assets/a4f02952-8d46-41ad-93cc-8369f0506618"
/> |

| Auto (OS light) | Auto (OS dark) |
|-----------------|----------------|
| <img width="400" alt="Theme switcher with Auto selected and a light
OS"
src="https://github.com/user-attachments/assets/2375d95d-7d64-4894-a3e2-5dea9a81d8b8"
/> | <img width="400" alt="Theme switcher with Auto selected and a dark
OS"
src="https://github.com/user-attachments/assets/65db64bb-d558-4459-9a98-5b8c34abbba4"
/> |
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