npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@brumeilde/ngx-theme

v1.2.1

Published

Library for dynamic mangement of theming and color palettes in Angular apps

Readme

ngx-theme


🔗 Stackblitz demo

Table of content

Purpose

This purpose of this lib is to manage dynamic themes accross Angular apps.

Requirements

  • Angular 12 or higher

Supported UI frameworks

  • ✅ Tailwind
  • ✅ Angular Material > 12.0.0

Principle

This library generates a palette with darker / lighter variants for each provided color based on the Material Design color system

Example of a palette format:

const primaryPalette: Palette = {
    50: '#FFEBEE',
    100: '#FFCDD2',
    200: '#EF9A9A',
    300: '#E57373',
    400: '#EF5350',
    500: '#F44336',
    600: '#E53935',
    700: '#D32F2F',
    800: '#C62828',
    900: '#B71C1C',
    contrast: {
        50: '#000000',
        100: '#000000',
        200: '#000000',
        300: '#000000',
        400: '#ffffff',
        500: '#ffffff',
        600: '#ffffff',
        700: '#ffffff',
        800: '#ffffff',
        900: '#ffffff',
    },
};

All these color shades are then inserted in the document as CSS variables and then used by Material and/or Tailwind to define their own theming which will be used by frontends (thanks to the presets).

Installation

yarn add @brumeilde/ngx-theme

Use

With NgxThemeModule :

forRoot config
type Palettes = { myPaletteName: string };
type Colors = { myColorName: string };

const colorConfig: IColorConfig<Palettes, Colors> = {
    palettes: { 
        myPaletteName: '#5876d9', 
        paletteWithContrast: { 
            baseColor: '#7FB5B5', 
            constrast: { dark: '#000000', light: '#ffffff' }, 
        },
    },
    simpleColors: { myColorName: '#2e959a' },
};

@NgModule({
    // ...
    imports: [
        NgxThemeModule.forRoot(colorConfig, {
            frameworks: ['tailwind'], // optional, default : ['tailwind', 'material']
        }),
    ],
    // ...
})
export class AppModule {}
Injection tokens
type Palettes = { myPaletteName: string; paletteWithConstrast: IDetailedColorInput; };
type Colors = { myColorName: string };

const colorConfig: IColorConfig<Palettes, Colors> = {
    palettes: { 
        myPaletteName: '#5876d9',
        paletteWithContrast: { 
            baseColor: '#7FB5B5', 
            constrast: { dark: '#000000', light: '#ffffff' }, 
        },
    },
    simpleColors: { myColorName: '#2e959a' },
};

@NgModule({
    // ...
    imports: [NgxThemeModule],
    providers: [
        { provide: COLOR_CONFIG, useValue: colorConfig },
        { provide: THEME_OPTIONS, useValue: { frameworks: ['tailwind'] } }, // optional, default : ['tailwind', 'material']
    ],
    // ...
})
export class AppModule {}

ℹ️ NgxThemeModule will generate color palettes on app initialization so the theme is created before app inits.

With NgxThemeService :

type Palettes = { myPaletteName: string };
type Colors = { myColorName: string };

export class AppComponent {
    constructor(
        private themeService: NgxThemeService<IColorConfig<Palettes, Colors>>) {}

    setAppColors(): void {
        this.themeService.updateColors({ palettes: { myPaletteName: '#5876d9' }});
    }

    get textColor(): string {
        return this.themeService.theme.getColorShade(300, 'myPaletteName');
    }
}

Add tailwind preset

// tailwind.config.js
const tailwindPreset = require('@brumeilde/ngx-theme/tailwind-preset');

const ngxThemePreset = tailwindPreset({
    palettes: ['myPaletteName', 'paletteWithContrast'],
    simpleColors: ['myColorName'],
});

module.exports = {
    // ...
    presets: [ngxThemePreset],
};

You can then use tailwind class with your color names:

<div class="bg-myColorName">
    <p class="text-myPaletteName-400/75">Theme</p>
</div>
<div class="bg-paletteWithContrast-600">
    <p class="text-paletteWithContrast-600-contrast">Constrast test</p>
</div>

Add material theme

// angular.json
   "stylePreprocessorOptions": {
        "includePaths": ["node_modules/@brumeilde/ngx-theme/presets/material"]
    },
/* styles.scss */
@use '@angular/material' as mat;
@use 'generate-material-palette' as palette;

$primary-palette: palette.createpalette('myPaletteName');
$accent-palette: palette.createpalette('myOtherPaletteName');
$warn-palette: palette.createpalette('myThirdPaletteName');

$material-primary-palette: mat.define-palette($primary-palette);
$material-accent-palette: mat.define-palette($accent-palette);
$material-warn-palette: mat.define-palette($warn-palette);

$my-theme: mat.define-light-theme(
    (
        color: (
            primary: $material-primary-palette,
            accent: $material-accent-palette,
            warn: $material-warn-palette
        )
    )
);

@include mat.core();

@include mat.all-component-themes($my-theme);

CSS

You can also directly use the generated css variables:

.my-text {
    background-color: var(--color-paletteWithContrast-700);
    color: var(--color-paletteWithContrast-700-contrast);
}

Incoming features

Whenever I get time 🙃

  • Material full scss palette generator
  • Rgb colors
  • Dark theme palettes