EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

How to use Dark mode by default ?

Open wehostadm opened this issue 2 years ago • 3 comments

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,

wehostadm avatar Apr 12 '23 09:04 wehostadm

Any update to this?

JeroenMoonen avatar Jan 12 '24 15:01 JeroenMoonen

Nothing guys really?

agaktr avatar Jun 13 '24 13:06 agaktr

@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.

dovereem avatar Aug 15 '24 08:08 dovereem