My own styles in angular material ui

前端 未结 3 2259
广开言路
广开言路 2021-02-15 09:21

material-ui and I want to customize it. Unfortunalety my own styles are overwritten by the framework styles. For example when I declare styles for md-toolbar

md         


        
3条回答
  •  佛祖请我去吃肉
    2021-02-15 10:00

    Best method which I know, without recompilling less, sass, etc.:

    You should apply custom theme:

    angular.module('myApp').config(['$mdThemingProvider', function($mdThemingProvider) {
        $mdThemingProvider.theme('myAwesome')
            .primaryPalette('blue')
            .accentPalette('cyan')
            .warnPalette('red');
        $mdThemingProvider.setDefaultTheme('myAwesome');
    }]);
    

    After that elements get class: md-myAwesome-theme so you can add style in your css (or less) file:

    md-select.md-myAwesome-theme {
        margin: 0;
        padding: 0;
    }
    

提交回复
热议问题