EasyAdminBundle
EasyAdminBundle copied to clipboard
How to use Dark mode by default ?
Short description of what this feature will allow to do: Is it possible to have the Dark mode by default and not let the user change ?
For the Light mode we can use disableDarkMode() function but there is nothing tor the opposite.
Thanks,
Any update to this?
Nothing guys really?
@wehostadm @JeroenMoonen @agaktr
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:
<body id="{% block body_id %}{% endblock %}" class="ea {% block body_class %}{% endblock %} ea-dark-scheme">
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.