{"id":47925474,"url":"https://github.com/fzankl/ngx-themes-plus","last_synced_at":"2026-04-04T06:29:27.695Z","repository":{"id":82910598,"uuid":"534304047","full_name":"fzankl/ngx-themes-plus","owner":"fzankl","description":"Perfect Angular theme support in two lines of code. Support system preferences and any other themes. Integrated theme switcher.","archived":false,"fork":false,"pushed_at":"2023-03-04T17:53:11.000Z","size":539,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T03:28:05.518Z","etag":null,"topics":["angular","dark-mode","dark-theme","theme-switcher","themes"],"latest_commit_sha":null,"homepage":"https://fzankl.github.io/ngx-themes-plus/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fzankl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-08T16:41:42.000Z","updated_at":"2023-07-13T13:58:49.000Z","dependencies_parsed_at":"2023-03-10T19:30:29.022Z","dependency_job_id":null,"html_url":"https://github.com/fzankl/ngx-themes-plus","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"c3624cad834e7bd8d987331177f59edb5aac86a4"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fzankl/ngx-themes-plus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzankl%2Fngx-themes-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzankl%2Fngx-themes-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzankl%2Fngx-themes-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzankl%2Fngx-themes-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fzankl","download_url":"https://codeload.github.com/fzankl/ngx-themes-plus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzankl%2Fngx-themes-plus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31390163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","dark-mode","dark-theme","theme-switcher","themes"],"created_at":"2026-04-04T06:29:26.955Z","updated_at":"2026-04-04T06:29:27.660Z","avatar_url":"https://github.com/fzankl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"./assets/logo_dark.svg\" /\u003e\n    \u003cimg alt=\"Shows the ngx-themes-plus logo.\" title=\"ngx-themes-plus\" src=\"./assets/logo_light.svg\" style=\"max-height: 175px;\" /\u003e\n  \u003c/picture\u003e\n  \u003cp\u003ePerfect Angular theme support in two lines of code.\u003cbr/\u003eSupport system preferences and any other themes. Integrated theme switcher.\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Build Status](https://github.com/fzankl/ngx-themes-plus/actions/workflows/main.yml/badge.svg)](https://github.com/fzankl/ngx-themes-plus)\n![Version](https://img.shields.io/npm/v/ngx-themes-plus.svg?colorB=green)\n[![npm Downloads](https://img.shields.io/npm/dt/ngx-themes-plus.svg)](https://www.npmjs.com/package/ngx-themes-plus)\n\n**⭐ Star the project on GitHub — it motivates a lot!**\n\u003c/div\u003e\n\n## Features\n\n- ✅ Perfect theme/dark mode support in two lines of code\n- ✅ Support for additional customized themes\n- ✅ System setting with prefers-color-scheme\n- ✅ Supports [Bootstrap color modes](https://getbootstrap.com/docs/5.3/customize/color-modes/) via custom data attribute\n- ✅ Themed browser UI with color-scheme\n- ✅ Integrated theme switcher (considers custom themes as well)\n- ✅ Sync theme across tabs and windows\n- ✅ Force pages to specific themes\n- ✅ Class or data attribute selector\n- ✅ Toggle element visibility based on a selected theme\n\nCheck out the [Live Example](https://fzankl.github.io/ngx-themes-plus/) to try it for yourself.\n\n## Install\n\n```bash\n$ npm install ngx-themes-plus\n```\n\n## Use\n\nYou have to add the module to the root module definition. The simplest `AppModule` looks like this:\n\n```js\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    BrowserModule,\n    ThemesModule.forRoot()\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\nAdding theme support takes 2 lines of code:\n\n```html\n\u003ctp-theme-provider\u003e\n  \u003crouter-outlet\u003e\u003c/router-outlet\u003e\n\u003c/tp-theme-provider\u003e\n```\n\nThat's it, your Angular app fully supports themes, including System preference with `prefers-color-scheme`. The theme is also immediately synced between tabs. By default, ngx-themes-plus modifies the `data-theme` attribute on the `html` element, which you can easily use to style your app:\n\n```css\n:root {\n  /* Your default theme */\n  --background: #FFF;\n  --foreground: #000;\n}\n\n[data-theme='dark'] {\n  --background: #000;\n  --foreground: #FFF;\n}\n```\n\n### Integrate with Bootstrap\n\nAs of version 5.3.0, Bootstrap supports different [color modes](https://getbootstrap.com/docs/5.3/customize/color-modes/). By default, a light and a dark mode are integrated. You can use all features of `ngx-themes-plus` by setting a custom `attribute` via the theme options. The next code snippet shows an example how to configure the plugin for use with Boostrap color modes.\n\n```js\nconst themeOptions = new ThemeOptions();\nthemeOptions.attribute = 'data-bs-theme';\n\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    BrowserModule,\n    ThemesModule.forRoot(themeOptions)\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\n### Switch themes\n\nngx-themes-plus supports switching themes using the integrated `theme-switcher` component. You can use it as easily as the parent component with an additional line of code.\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://user-images.githubusercontent.com/44210522/221420928-f29c8b48-eddd-4d03-9742-31f424a5eb31.png\" /\u003e\n  \u003cimg alt=\"Shows an example of the integrated theme switcher.\" title=\"Integrated theme switcher\" src=\"https://user-images.githubusercontent.com/44210522/221420926-d86537a6-7428-4f42-a407-4455135b0102.png\" /\u003e\n\u003c/picture\u003e\n\nWhen using the two default themes `light` and `dark` the `theme-switcher` uses some default icons. The following snippet shows the simplest implementation when using the default themes:\n\n```html\n\u003ctp-theme-provider\u003e\n  \u003ctp-theme-switcher\u003e\u003c/tp-theme-switcher\u003e\n\u003c/tp-theme-provider\u003e\n```\n\nWhen your application requires additional colors you can extend the themes via the options during bootstrapping.\n\n```js\nconst options = new ThemeOptions();\noptions.themes = [...options.themes, 'yellow'];\n\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    BrowserModule,\n    ThemesModule.forRoot(options)\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\nFor the theme to be displayed correctly, the styles need to be extended. \n**Take care about adding the color definition `--theme` for each theme since that color is used by the `theme-switcher` to render its selection.**\n\n```css\n:root {\n  /* Your default theme */\n  --background: #FFF;\n  --foreground: #000;\n}\n\n[data-theme=\"light\"] {\n  --theme: #f6f4e6;\n}\n\n[data-theme=\"dark\"] {\n  --theme: #27272A;\n\n  --background: #27272A;\n  --foreground: #f6f4e6;\n}\n\n[data-theme=\"yellow\"] {\n  --theme: #FACC15;\n\n  --background: #E4E4E7;\n  --foreground: #18181B;\n}\n```\n\n### Force theme\n\nA forced theme is the right option if you like to present a page using a specific theme only. Switching themes does not have an effect.\n\nTo force a theme on your Angular pages, simply inject the `ThemeProviderComponent` via the constructor and set the theme you like. Integrated `theme-switcher` is disabled in this case.\n\n```js\n@Component({\n  selector: 'app-page-forced'\n})\nexport class ForcedPageComponent implements OnDestroy {\n  constructor(private readonly themeProvider: ThemeProviderComponent) {\n    this.themeProvider.forcedTheme = 'dark';\n  }\n\n  public ngOnDestroy(): void {\n    this.themeProvider.forcedTheme = '';\n  }\n}\n```\n\nA second possibility is to set the value of the property `forcedTheme` via template binding.\n\n```html\n\u003ctp-theme-provider [forcedTheme]=\"forcedTheme\"\u003e\n  \u003c!-- Content --\u003e\n\u003c/tp-theme-provider\u003e\n```\n\n```js\n/*\n * The way how you enforce a specific theme depends upon \n * the possibilities of your application.\n * The `AppConfigService` is just a kind of placeholder \n * for any application specific logic. \n */\n@Injectable({ providedIn: 'root' })\nexport class AppConfigService {\n  private _forcedTheme$ = new BehaviorSubject\u003cstring | undefined\u003e(undefined);\n  public forcedTheme$ = this._forcedTheme$.asObservable();\n\n  public forceTheme(theme?: string): void {\n    this._forcedTheme$.next(theme);\n  }\n}\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.scss']\n})\nexport class AppComponent {\n  public forcedTheme: string | undefined;\n\n  constructor(private readonly appConfigService: AppConfigService) {\n    // Set the forced theme using any application specific logic.\n    this.appConfigService.forcedTheme$.subscribe({\n      next: (theme) =\u003e this.forcedTheme = theme\n    });\n  }\n}\n\n@Component({\n  selector: 'app-page-forced'\n})\nexport class ForcedPageComponent implements OnDestroy {\n  constructor(private readonly appConfigService: AppConfigService) {\n    this.appConfigService.forceTheme('dark');\n  }\n\n  public ngOnDestroy(): void {\n    this.appConfigService.forceTheme();\n  }\n}\n```\n\n### Theme-specific elements\n\nIt may be possible to show or hide elements depending on the selected theme, e.g. a specific logo. The library exposes the directives `tpThemesOnly` and `tpThemesExcept` that can show/hide elements of your application based on the selected theme.\n\nThe directive accepts several attributes:\n\n| Attribute               | Value                   | Description|\n| :---------------------- | :---------------------- | :---------------------- |\n| `tpThemesOnly` | `[String \\| String[]]` | Single or multiple themes for which the associated element should be shown |\n| `tpThemesExcept` | `[String \\| String[]]` | Single or multiple themes for which the associated element should not be shown |\n\nThe logo within the showcase is changed using both directives shown in the following snippet:\n\n```html\n\u003cdiv class=\"logo\"\u003e\n  \u003cimg *tpThemesOnly=\"'dark'\" src=\"path-to-the-image\" /\u003e\n  \u003cimg *tpThemesExcept=\"'dark'\" src=\"path-to-the-image\" /\u003e\n\u003c/div\u003e\n```\n\n## Troubleshooting\n\nIf theme support does not work as expected, check that your application configuration is valid according to this documentation. If that doesn't help, please feel free to open an issue.\n\n## Changelog\n\n03/04/2023\n  * Initial release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzankl%2Fngx-themes-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffzankl%2Fngx-themes-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzankl%2Fngx-themes-plus/lists"}