Recently Symfony EasyAdmin added a darkmode and a theme selector.
They also added an option to disable darkmode, but there is no option to disable lightmode.
How can you permanently enable darkmode and disable the themeselector?
Here is a solution:
Copy file vendor/easycorp/easyadmin-bundle/src/Resources/views/layout.html.twig to /templates/bundles/EasyAdminBundle/layout.html.twig and edit that file.
Comment out this line (This is on the tag somewhere around row 61):
data-ea-dark-scheme-is-enabled=”{{ ea.dashboardHasDarkModeEnabled ? ‘true’ : ‘false’ }}”
Then add ea-dark-scheme to the class=”” attribute on the body resulting in:
class=”ea {% block body_class %}{% endblock %} ea-dark-scheme”
Then copy file vendor/easycorp/easyadmin-bundle/src/Resources/views/page/login_minimal.html.twig to /templates/bundles/EasyAdminBundle/page/login_minimal.html.twig and edit that file.
Here just add ea-dark-scheme to the classes on the body like so:
To finish it off go and edit the DashboardController. Find the configureDashboard method and edit it like this:
return Dashboard::new()
->setTitle('Nexus')
->disableDarkMode(true);
This disables the theme selector.
Doing the above results in dark theme everywhere without the theme selector visible.