maikschneider/login-color-scheme

Color-scheme aware TYPO3 backend login: adds a dark mode variant for the login background image.

Maintainers

Package info

github.com/maikschneider/login-color-scheme

Type:typo3-cms-extension

pkg:composer/maikschneider/login-color-scheme

Transparency log

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-08-07 15:29 UTC

This package is auto-updated.

Last update: 2026-08-07 18:54:41 UTC


README

TYPO3 13 TYPO3 14 License

The TYPO3 backend login screen follows the visitor's preferred color scheme, but the core setting [BE][loginBackgroundImage] accepts only one image. This extension adds a second setting for the image to use while the dark color scheme is active.

TYPO3 backend login screen, light mode with a bright background image on the left, dark mode with a dark background image on the right

Related: forge issue #106760.

Requirements

TYPO3 PHP
13.4 LTS ≥ 8.2
14.x ≥ 8.3

Installation

composer require maikschneider/login-color-scheme

Configuration

The extension adds a single setting, backgroundImageDark. Set it in Admin Tools → Settings → Extension Configuration → login_color_scheme, or in config/system/settings.php:

'EXTENSIONS' => [
    'backend' => [
        // light color scheme, handled by TYPO3 core
        'loginBackgroundImage' => 'EXT:my_sitepackage/Resources/Public/Images/login.jpg',
    ],
    'login_color_scheme' => [
        // dark color scheme, handled by this extension
        'backgroundImageDark' => 'EXT:my_sitepackage/Resources/Public/Images/login-dark.jpg',
    ],
],

The value accepts the same formats as the core setting: an EXT: path, a path relative to the project root such as fileadmin/login-dark.jpg, or an absolute URL.

Configuring only the dark image is valid. Light mode then falls back to the plain background color, as it does in an unconfigured TYPO3.

How it works

A backend middleware adds one inline CSS block to every route that renders the login layout — login, login refresh, password reset and MFA:

@media (prefers-color-scheme: dark) {
    :root:not([data-color-scheme="light"]) .typo3-login { background-image: url("…"); }
}
:root[data-color-scheme="dark"] .typo3-login { background-image: url("…"); }

Two rules are needed because the backend has three color scheme states. The authentication screens carry no data-color-scheme attribute and therefore follow the operating system, while a logged-in user reaching the login refresh dialog may have pinned light or dark in their user settings.

The selectors are more specific than the core .typo3-login rule, so the override applies regardless of render order. The URL is escaped with GeneralUtility::sanitizeCssVariableValue(), the same helper core uses, and the block is emitted with a CSP nonce.

Limitations

The extension covers the background image only. The login logo (loginLogo) and the highlight color (loginHighlightColor) are not color scheme aware either, but the logo is inlined by a ViewHelper and needs a different approach — see forge issue #107558.

Development

composer install
composer sca      # composer normalize, editorconfig, php lint, php-cs-fixer, phpstan, xliff
composer tests    # unit tests

Bug reports and pull requests are welcome, see CONTRIBUTING.md.

License

GPL-2.0-or-later