Star5

Theming

Five built-in themes, all driven by the same token layer. Switch below to see every component respond instantly — no per-component overrides needed. To customize colors or shape, override semantic tokens after the import. Full token reference →

Live preview

light

Buttons

Badges & chips

DefaultSuccessWarningDangerInfoPurple
Angular
Signals
SSR
Beta

Alerts

Progress

Default
Success
Warning
Danger

Avatars

Form controls

How to set it up

Four steps from install to theme-switched runtime.

  1. Import global styles

    Loads every token tier and all five theme definitions in one line.

    styles.scssscss
    @use 'zyra-ng-ui';
    
  2. Register the theme provider

    Picks the initial theme and wires up ZyraThemeService before first render.

    app.config.tsts
    import { provideZyra } from 'zyra-ng-ui';
    
    export const appConfig: ApplicationConfig = {
      providers: [provideZyra({ theme: 'dark' })],
    };
    
  3. Switch themes at runtime

    Inject the service anywhere — every component repaints instantly, no reload.

    ts
    import { Component, inject } from '@angular/core';
    import { ZyraThemeService } from 'zyra-ng-ui';
    
    @Component({ /* ... */ })
    export class MyComponent {
      private theme = inject(ZyraThemeService);
    
      switchTheme() {
        this.theme.setTheme('ocean'); // 'dark' | 'light' | 'ocean' | 'amber' | 'rose'
      }
    }
    
  4. Override tokens (optional)

    Set any token after the Zyra import to customize without forking a theme file.

    styles.scssscss
    :root {
      --zyra-color-primary: #7c3aed; /* semantic Tier 2 — propagates everywhere */
      --zyra-radius-md: 6px;         /* dimension Tier 1 — affects all md-radius components */
    }
    

ZyraThemeService API

Signal-based, SSR-safe, tree-shakeable.

MemberReturnsDescription
themeSignal<ZyraTheme>Read-only signal with the currently active theme name.
setTheme(theme: ZyraTheme)voidSwitch to a named theme. Persists to localStorage automatically.
toggleTheme()voidCycle through all available themes in order.
isDarkSignal<boolean>True when the active theme uses a dark color scheme.

provideZyra() options

Passed once in app.config.ts. All fields optional.

OptionTypeDefaultDescription
theme'dark' | 'light' | 'ocean' | 'amber' | 'rose''dark'Initial theme applied before Angular hydrates.
respectSystemThemebooleanfalseUse OS prefers-color-scheme when no localStorage value is saved.
storageKeystring'zyra-theme'localStorage key used to persist the user's last choice.