19.2.0 • Published 6 months ago
@christophhu/ngx-dark-mode v19.2.0
Ngx-Dark-Mode
Frameworks and Languages
Demo
Description
This Repository contains a simple Angular library for toggling between light and dark mode. It is designed to be easy to use and integrate into any Angular application.
It uses the localStorage API to save the user's preference for dark mode, so that the setting persists across page reloads.
Installation
npm i @christophhu/ngx-dark-modeUse
With default toggle
<dark-mode></dark-mode>With custom toggle
<dark-mode>
<input type="checkbox" class="toggle" id="toggle" (change)="toggleTheme()"/>
</dark-mode>import { DarkModeService, DarkModeComponent, Theme } from "@christophhu/ngx-dark-mode-toggle";
import { DarkModeService } from '@christophhu/ngx-dark-mode';
@Component({
...
imports: [
DarkModeComponent
],
providers: [
DarkModeService
]
})
export class TestComponent {
constructor(private _darkModeService: DarkModeService) {}
toggleTheme() {
this._darkModeService.toggleTheme()
}
getTheme(): Observable<Theme> {
return this._darkModeService.theme$
}
}19.2.0
6 months ago