Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Angular
  3. angular-material-css-vars

angular-material-css-vars

MITSCSSv10.0.0

A library to dynamically style Angular Material components using CSS custom properties (CSS variables).

Visit WebsiteGitHubGitHub
197 stars36 forks0 contributors

What is angular-material-css-vars?

angular-material-css-vars is a library that enables dynamic theming of Angular Material components using CSS custom properties. It solves the limitation of Angular Material's static theming by allowing developers to change theme colors, contrast, and density at runtime. This provides greater flexibility for applications requiring live theme adjustments.

Target Audience

Angular developers using Angular Material (M2) who need to implement dynamic, runtime-adjustable themes in their applications. It is particularly useful for those building applications with user-customizable themes or requiring theme switching (e.g., light/dark mode).

Value Proposition

Developers choose this library because it bridges Angular Material's static theming with the dynamic capabilities of CSS variables, offering runtime theme control without sacrificing compatibility. Its unique selling point is the ability to programmatically adjust colors, contrast, and density via a service while exposing design tokens as CSS custom properties for custom styling.

Overview

Little library to use css variables with @angular/material

Use Cases

Best For

  • Implementing user-customizable theme colors (primary, accent, warn) in real-time within Angular Material applications.
  • Building applications that require dynamic light/dark theme toggling with automatic contrast adjustment for accessibility.
  • Creating Angular Material-based projects where theme colors need to be changed programmatically via a service at runtime.
  • Integrating CSS custom properties with Angular Material's design tokens to enable custom styling beyond the default theming system.
  • Adjusting global density levels and typography in Angular Material using SCSS mixins and configuration.
  • Supporting legacy Angular Material components (pre-MDC) via the separate legacy package, when migrating from older versions.

Not Ideal For

  • Projects using Angular Material v18 or later that require the modern M3 theme system
  • Applications with static, unchanging themes where the setup overhead isn't justified
  • Teams that prefer Angular Material's default theming without modifying core stylesheet imports
  • Server-side rendered apps where runtime CSS variable changes might cause visual flicker

Pros & Cons

Pros

Dynamic Runtime Theming

Enables changing theme colors, contrast, and density at runtime via MaterialCssVarsService, allowing live adjustments without page reloads, as demonstrated in the setup examples.

CSS Variable Integration

Exposes Angular Material's design tokens as CSS custom properties, providing flexibility for custom styling with utility mixins like mat-css-color-primary for SCSS access.

Auto Contrast Accessibility

Automatically adjusts contrast colors based on thresholds via setAutoContrastEnabled, ensuring WCAG compliance without manual calculations, with options for fine-tuning.

Flexible Configuration Options

Supports custom typography, density levels, and dark/light theme selectors through SCSS mixins and initialization parameters, as shown in the font config and density sections.

Cons

No M3 Theme Support

The README explicitly states it only supports Angular Material M2, not the stable M3 theme introduced in v18, limiting use in newer projects without workarounds.

Complex Initial Setup

Requires removing Angular Material's core mixin (@include mat.core()) and replacing it with library code, which can break existing setups and increase configuration errors.

Tight Angular Version Coupling

The compatibility table shows strict version matching with Angular, leading to frequent breaking changes and maintenance overhead during upgrades.

Legacy Component Fragmentation

For pre-MDC components, a separate legacy package is needed, adding complexity and potential inconsistencies in projects with mixed component versions.

Frequently Asked Questions

Quick Stats

Stars197
Forks36
Contributors0
Open Issues6
Last commit6 months ago
CreatedSince 2019

Tags

#hacktoberfest#angular-material#css-variables#theme-engine#frontend#ui-library#dynamic-theming#angular#material-design#scss

Built With

A
Angular
S
SCSS
T
TypeScript

Links & Resources

Website

Included in

Angular10.0k
Auto-fetched 1 day ago

Related Projects

CovalentCovalent

Covalent - A Design System for Teradata

Stars2,227
Forks352
Last commit2 days ago
MDBootstrapMDBootstrap

Angular 21 & Bootstrap 5 & Material Design UI KIT

Stars1,146
Forks273
Last commit3 months ago
IgniteUI AngularIgniteUI Angular

Ignite UI for Angular is a complete library of Angular UI components with the fastest grids and charts, dock manager, and more.

Stars597
Forks160
Last commit2 days ago
@ng-matero/extensions@ng-matero/extensions

Angular Material Extensions Library.

Stars498
Forks71
Last commit15 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub