Core
Glass Provider
Holds the theme, glass mode and accessibility settings the whole app shares.
Preview
Installation
Install the package once, then import the parts you use into a standalone component.
Install
npm install ngx-vitreo @angular/cdk @floating-ui/domImport
import { GlassPreferences, GlassProvider, GlassLiquidFilters } from 'ngx-vitreo';
@Component({
imports: [GlassPreferences, GlassProvider, GlassLiquidFilters],
// ...
})Usage
Usage
// app.config.ts
export const appConfig: ApplicationConfig = {
providers: [provideVitreo({ defaultTheme: 'light' })],
};
// any component
const glass = inject(GlassPreferences);
glass.setPreferences({ theme: 'dark' });API reference
provideVitreo
provideVitreo(options?)
| Input | Type | Default | Description |
|---|---|---|---|
light | 'motion' | 'fixed' | 'motion' | What moves the light the rim highlights are lit by: the device tilt (still on a desktop), or nothing. |
defaultTheme | 'light' | 'dark' | system setting | Theme a visitor sees until they choose one; without it the provider follows prefers-color-scheme. A saved choice always wins. |
GlassPreferences
inject(GlassPreferences)
| Input | Type | Default | Description |
|---|---|---|---|
preferences | Signal<Required<VitreoPreferences>> | None | theme, mode, quality, reduceMotion, reduceTransparency and thickness, resolved from the visitor’s choices, the system and the defaults. |
setPreferences | (prefs: Partial<VitreoPreferences>) => void | None | Merges and applies the given preferences, and saves them to localStorage under vitreo-preferences. |
active | Signal<boolean> | false | Whether a provider holds the preferences. Without one, glass reads the defaults and the system reduced-transparency setting, and setPreferences does nothing. |
GlassProvider
<glass-provider>
| Input | Type | Default | Description |
|---|---|---|---|
defaultTheme | 'light' | 'dark' | system setting | Template form of provideVitreo(). |
GlassLiquidFilters
<glass-liquid-filters>