Skip to main content
The Appearance module exposes information about the user’s appearance preferences, such as their preferred color scheme (light or dark).

Methods

getColorScheme()

Returns the current color scheme preference. The value may change, so you should not cache it without listening to changes or using the useColorScheme hook. Returns:
  • 'light' - Light color scheme is preferred
  • 'dark' - Dark color scheme is preferred
  • null - No preference or unable to determine
Example:

setColorScheme()

Updates the current color scheme to the supplied value. Parameters:
  • colorScheme: The color scheme to set
    • 'light' - Light mode
    • 'dark' - Dark mode
    • 'unspecified' - Use system default
Example:

addChangeListener()

Add an event handler that is fired when appearance preferences change. Parameters:
  • listener: Function to call when the color scheme changes
Returns:
  • EventSubscription object with a remove() method to unsubscribe
Example:

Hook

For functional components, use the useColorScheme hook instead:

Platform Differences

  • iOS: Reflects the system-wide appearance setting from Settings > Display & Brightness
  • Android: Reflects the system dark theme setting (Android 10+)
  • Web: May reflect the browser/OS preference via prefers-color-scheme media query