LynxTheme
The light or dark appearance the app is drawn in, the device's own, and on Android its wallpaper's colors, as signals. import { LynxTheme, provideColorScheme } from '@blotch/angular-lynx';
Usage
The page element has the dark class while appearance() is 'dark', so a stylesheet's dark values go under page.dark. See Dark mode.
API
LynxTheme
Reads the theme value that the host app sets in its global data. The host usually sets it from the operating system's appearance setting. In the web preview, where no host sets one, it's the browser's prefers-color-scheme.
LynxTheme.appearance
What the app is drawn in: its own choice (see colorScheme), or the device's while that's 'system'.
LynxTheme.colorScheme
The app's choice: 'system' (the default) follows the device, and 'light' and 'dark' keep to one.
LynxTheme.setColorScheme()
Sets the app's choice. It lasts until the app closes: store the user's choice and set it again at the next start.
LynxTheme.theme
The device's theme, whatever the app chose. 'Light' when the host sets none and no browser prefers dark.
LynxTheme.isDarkMode
true when theme() is 'Dark'.
provideColorScheme()
Sets the app's choice from its first frame, in app.config.ts. An app with no dark design uses provideColorScheme('light').
LynxTheme.dynamicColors
The colors Android 12 and later take from the user's wallpaper (Material You's dynamic color), as Material 3's color roles, in a light and a dark scheme. null where the host app sends none.
- It comes from the host app, in its
dynamicColorsGlobalData value:{ light, dark }, each with a hex color, such as#6750a4, for every role inDYNAMIC_COLOR_ROLES. A scheme with a role missing counts as none. - The Android app
ng build --platform androidbuilds sends it, and sends it again when the user changes their wallpaper or colors. iOS, the web preview and Lynx Explorer have none. - Both schemes come at once, so an app that keeps its own light or dark theme can use the right one.
- To color the UI components with it, use Dynamic Color.
Types
LynxColorScheme
LynxAppearance
DynamicColors
DynamicColorScheme
Each role's color, as a hex color such as #6750a4.
DynamicColorRole
One of Material's color roles, as DYNAMIC_COLOR_ROLES lists them:
primary,onPrimary,primaryContainer,onPrimaryContainer,inversePrimarysecondary,onSecondary,secondaryContainer,onSecondaryContainertertiary,onTertiary,tertiaryContainer,onTertiaryContainerbackground,onBackground,surface,onSurface,surfaceVariant,onSurfaceVariantsurfaceDim,surfaceBright,surfaceContainerLowest,surfaceContainerLow,surfaceContainer,surfaceContainerHigh,surfaceContainerHighestinverseSurface,inverseOnSurface,outline,outlineVariant
The error roles aren't there: Material keeps errors red whatever the wallpaper.
Related
- Dark mode: switch your styles with the theme.
- Dynamic Color: color the UI components with the wallpaper's colors.
- Host data:
LynxGlobalData, where the value comes from. - System info
