Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the background color of angular-material switch without loosing ripple effect

How can I change the color of angular-material's switch button without loosing the ripple effect?

Please see code pen here: http://codepen.io/shyambhiogade/pen/LpNGBP

I have changed the color to #03A9F4 and now the ripple effect is not working properly...

Code below:

<div class="inset switchdemoBasicUsage" ng-controller="SwitchDemoCtrl" ng-app="MyApp">
  <md-switch class="md-primary" md-no-ink="" aria-label="Switch No Ink" ng-model="data.cb5">
    Switch (md-primary): No Ink
  </md-switch>
</div>
like image 596
shyam_ Avatar asked Feb 09 '23 00:02

shyam_


1 Answers

You need to use $mdThemingProvider provider to modify elements style.

http://plnkr.co/edit/FRwd2fmmn0byBVUKYKi9?p=preview

angular.module('MyApp', ['ngAria', 'ngAnimate', 'ngMaterial'], function($mdThemingProvider) {
  var blueTheme = $mdThemingProvider.theme('blueTheme', 'default');
  var bluePalette = $mdThemingProvider.extendPalette('blue', {
    '500': '#03A9F4'
  });
  $mdThemingProvider.definePalette('bluePalette', bluePalette);
  blueTheme.primaryPalette('bluePalette');
})

.controller('SwitchDemoCtrl', function($scope) {});
<html>
<head>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/0.11.0/angular-material.min.css">
  	<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/0.11.0/angular-material.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular-animate.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular-aria.min.js"></script>
</head>
<body ng-app="MyApp" md-theme="blueTheme" ng-controller="SwitchDemoCtrl">
   <div class="inset switchdemoBasicUsage">
  
  <md-switch class="md-primary" md-no-ink="" aria-label="Switch No Ink" ng-model="data.cb5">
    Switch (md-primary): No Ink
  </md-switch>
</div>
</body>
</html>
like image 82
Mohamed El-Sayed Avatar answered May 23 '23 03:05

Mohamed El-Sayed