Skip to main content
cngx-src documentation

provideContrast

Functioncore/themingv0.1.0

projects/core/theming/contrast.ts

Description#

Install the contrast preference at app root and reflect it onto <html data-contrast>, driving the higher-contrast token overrides in contrast-tokens.css. Like the motion reflector, this one removes the attribute for 'auto' so the OS prefers-contrast: more media query stays in charge, and sets it for 'more' / 'normal'. The reflector is an effect (not afterNextRender) so it re-runs on every runtime injectContrast().set(...); the DOM write is wrapped in untracked() per the signal-architecture rules.

bootstrapApplication(AppComponent, {
  providers: [provideContrast('more')],
});

Signature#

provideContrast(initial: CngxContrastPreference)

Parameters#

@paraminitialCngxContrastPreference= 'auto'

Returns#

EnvironmentProviders