mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-28 13:18:49 +01:00
feat(demo): add landing page with docs (#1951)
This commit is contained in:
parent
67c9587b87
commit
43cc3a1556
190 changed files with 15425 additions and 21 deletions
54
docs/articles/theme-change.md
Normal file
54
docs/articles/theme-change.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# Change Current Theme
|
||||
|
||||
Nebular Theme System provides 3 color schemes out of the box - `default`, `corporate` and `cosmic`. It is both possible to change the theme statically and dynamically during the runtime.
|
||||
|
||||
|
||||
## Switch from Cosmic to Default
|
||||
It is extremely simple to replace a theme from one to another.
|
||||
All you need to do is to find your `NbThemeModule.forRoot` declaration and change a value of the `name` setting:
|
||||
|
||||
```ts
|
||||
@NgModule({
|
||||
imports: [
|
||||
// ...
|
||||
NbThemeModule.forRoot({ name: 'default' }),
|
||||
],
|
||||
}
|
||||
```
|
||||
<hr>
|
||||
|
||||
## Runtime Theme Switch
|
||||
In case you want to have a better control when a theme is changed, or for instance need to change it based on a user role,
|
||||
it is possible to dynamically tell Nebular which theme should be enabled.
|
||||
`NbThemeService` is our friend in this case and particularly the `changeTheme` method:
|
||||
|
||||
```ts
|
||||
|
||||
// ...
|
||||
constructor(private themeService: NbThemeService) {
|
||||
this.themeService.changeTheme('corporate');
|
||||
}
|
||||
|
||||
```
|
||||
<hr>
|
||||
|
||||
## Listen to Theme Change
|
||||
And of course it is possible to subscribe to an event when the current theme gets changed so that you can adjust something in your code accordingly:
|
||||
|
||||
```ts
|
||||
|
||||
// ...
|
||||
constructor(private themeService: NbThemeService) {
|
||||
|
||||
this.themeService.onThemeChange()
|
||||
.subscribe((theme: any) => {
|
||||
console.log(`Theme changed to ${theme.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
```
|
||||
<hr>
|
||||
|
||||
## Related Articles
|
||||
|
||||
- [Theme System](docs/guides/theme-system)
|
||||
Loading…
Add table
Add a link
Reference in a new issue