Themes = "light" | "system" | "dark"
I think theme is set to "system" by default in pref right? Is there any way to define that I want light mode to be default for all?
I don't think there is an easy way to set the default theme at the moment. Here you can find the main logic:
https://github.com/payloadcms/payload/blob/master/src/admin/components/utilities/Theme/index.tsxI'd probably bypass this problem using:
1. Custom provider
https://payloadcms.com/docs/admin/components#custom-providers2. useTheme hook which you can import like that:
import { useTheme } from 'payload/dist/admin/components/utilities/Theme';
You should be able to set the theme in useEffect using
setTheme
function. It's my first idea and maybe there is a better way. If you will go with this solution remember to call
setTheme
only once (to allow users to change theme in dashboard settings,
Automatic
can be problematic and may require additional flag in localStorage)
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.