Microapp provides SDKs to manage the user’s theme mode, and then passes it to your microapp so that you can style content accordingly.Here is how you can use the theme in your microapp:
To use the User Preferences SDK in your code, import it in any file where you need to use it.
Copy
import { UserPreferences } from '@microapp-io/user-preferences';// Production initializationconst userPreferences = new UserPreferences();// Sandbox initialization with custom preferencesconst userPreferences = new UserPreferences({ sandbox: { theme: 'dark', },});
When developing locally, you can use the sandbox configuration to test different user preferences. In production, initialize without any parameters to automatically detect the user’s preferences.
The User Preferences SDK provides a way to listen to updates to the user’s preferences. You can use the onPreferencesChange function to listen to changes to the user’s preferences.