Scoped Theme
There are cases where you may want to render specific components or screens with a fixed theme. For instance, a Camera
view might require a dark background for better contrast, even if the user has selected light mode for the app. Other examples include modals, dialogs, or enabling users to preview the app in different themes to choose their preferred one.
To address this, Unistyles 3.0 introduces the concept of a Scoped Theme
, which allows you to assign a fixed theme to a specific component or screen.
Usage
To use scoped theme, you need to import ScopedTheme
component from react-native-unistyles
:
Scoped theme accepts one of your registered theme names as a prop:
You can also nest ScopedTheme
components: