Skip to content
⭐ Loving ngx-theme-stack? Support us with a star on GitHub!

Getting Started

ngx-theme-stack banner

A simple and powerful headless theme manager for Angular 20+. Built for performance and SSR support.

To install the library and configure it automatically in your project, run:

Terminal window
ng add ngx-theme-stack

When running ng add, you will be presented with two configuration options:

  • Applies default configuration instantly.
  • Initial theme: system.
  • Apply mode: class (adds the theme class to the <html> element).
  • Available themes: ['light', 'dark', 'system'].
  • Strategy: critters (Zero-flash via CSS inlining).

To provide a “Zero Config” experience, the installation command automates the following:

  • Directory.agents/
    • Directoryskills/
      • Directoryngx-theme-stack/
        • SKILL.md (Optional AI Agent Skill)
  • Directorypublic/
  • Directorysrc/
    • Directoryapp/
      • app.config.ts (Configure providers here)
      • app.routes.ts
      • app.ts
      • app.html
      • app.css
    • index.html (Injects anti-flicker script and marker)
    • main.ts
    • styles.css
    • themes.css (New! Base file with CSS variables)
  • angular.json (Registers styles and critical CSS optimization)
  • package.json (Adds “ngx-theme-stack:sync”, “prestart”, and “prebuild” scripts)
  • tsconfig.json

Inject the services in your components using Angular’s inject() function.

ngx-theme-stack provides different utilities to interact with themes:

Socket Badge

Security is a core design principle for ngx-theme-stack. The library achieves a 100/100 score on Socket.dev across all main categories (Supply Chain Security, Vulnerability, Quality, Maintenance, and License):

  • Supply Chain Security: Strict dependency scanning and pinning via overrides to prevent malicious updates.
  • Vulnerabilities: Zero known vulnerabilities in both production and development environments.
  • Runtime Safety: The anti-flash blocking script validates all theme inputs against a strict regular expression (/^[a-zA-Z][a-zA-Z0-9_-]*$/) and checks against configured themes before making any DOM updates, preventing injection attacks.
  • Static Template Compilation: Schematic templates are converted directly to TypeScript assets to eliminate raw markdown parsing alerts and ensure build-time safety.

Now that you have the library installed, you can: