Skip to main content
With Privy, you can style your login modal to match your user’s system preferences for light or dark mode. Below is a short guide for how to configure your login modal to match your user’s system settings.

1. Get your user’s system preferences

To start, you should determine if your user’s system preferences are configured for light mode, or for dark mode.Based on their system preferences, your user’s device will automatically set the prefers-color-scheme CSS media feature in your website to indicate their light/dark preference. You can simply query this media feature to determine if your user prefers light or dark mode. Below is a sample React hook to determine if your user prefers light or dark mode; feel free to use this directly in your app!

2. Construct a light and dark theme

Next, in your frontend code, create an appearance configuration object for both light and dark mode. You can use the default Privy light and dark themes, e.g.:
Or, you can create custom lightModeConfig and darkModeConfig objects (with custom themes and accentColors) to match the modal’s light and dark modes with your app’s branding.

3. Conditionally set your theme based on the user’s system preferences

Lastly, in your PrivyProvider, conditionally pass in the lightModeConfig (your light mode configuration object) or darkModeConfig (your dark mode configuration object) depending on the user’s system preferences from step 1.
That’s it! Your Privy modal’s theme will now automatically match the user’s system preference for light or dark mode.