
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
angular-material-css-vars
Advanced tools
You want to style your angular material dynamically with all the colors in the rainbow and don't really care about IE11 (support for css variables is required)? Look no further!
npm i angular-material-css-vars -S
@import '~@angular/material/theming';
from your main stylesheet file if present.@import '~angular-material-css-vars/main';
@include initMaterialCssVars();
import {MaterialCssVarsService} from 'angular-material-css-vars';
export class SomeComponentOrService {
constructor(public materialCssVarsService: MaterialCssVarsService) {
const hex = '#3f51b5';
this.materialCssVarsService.setDarkTheme(true);
this.materialCssVarsService.changePrimaryColor(hex);
this.materialCssVarsService.changeAccentColor('#333');
}
}
switchToDarkContrastColor()
switchToLightContrastColor()
setAutoContrastEnabled(bool)
changeContrastColorThreshold(hueVal: HueValue)
setVariable(cssVarName: MaterialCssVariables, value: string)
MaterialCssVariables
enum from here to make sure you get the variable name right.setDarkTheme(isDark: boolean)
There are also several utility functions and mixins.
@import '~angular-material-css-vars/public-util';
.with-color {
border-color: mat-css-primary-color(300);
}
.color-and-contrast {
@include mat-css-color-and-contrast(300);
}
.with-bg {
@include mat-css-bg(300);
}
You can provide different options during initialization to change the body class used for the dark theme and to provide different default styles:
@mixin initMaterialCssVars(
$default-theme: $css-vars-default-light-theme,
$dark-theme-body-class: 'isDarkTheme',
$default-theme-text: $css-vars-text
) {
// ...
}
A full list of the theme map can be found here.
...goes to @zbirizdo project on which parts of this are based which is in turn supposedly based on this gist.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
FAQs
Little library to use css variables for @angular/material
The npm package angular-material-css-vars receives a total of 2,352 weekly downloads. As such, angular-material-css-vars popularity was classified as popular.
We found that angular-material-css-vars demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.