Unique take on the Material Design Lite Theme, customized with Gulp and Sass tweaks

I am interested in implementing a personalized version of a Material Design Lite "theme".

MDL is essentially the CSS and JS components of Material Design that have been extracted for use in web applications. While MDL provides a web interface to generate a CSS file using their preset theme color variations, we prefer to customize our own colors.

I have integrated MDL with Bower and am utilizing SASS to compile the components.

In addition to modifying the MDL files directly, I am seeking guidance on how and where to override the following variables:

$color-primary: $palette-red-500 !default;
$color-primary-dark: $palette-red-700 !default;
$color-accent: $palette-pink-A200 !default;

// Our primary is dark, so use $color-dark-contrast for overlaid text.
$color-primary-contrast: $palette-green-700 !default;
// Our accent is dark, so use $color-dark-contrast for overlaid text.
$color-accent-contrast: $palette-green-700 !default;

Additional Information:

Within the MDL codebase, the

bower_components/material-design-lite/src/_variables.scss
file contains the predefined theme variables (as shown above), which can be manually adjusted. However, I am exploring ways to supersede them from an external source.

I attempted to include the variables in my own

assets/styles/common/_variables.scss
file, but it seems that by the time Gulp processes this document, the variables within the component have already influenced the styles:

@import "../../bower_components/material-design-lite/src/color-definitions";
//@import "functions";

$trim-color-classes: false !default;

// Use color primarily for emphasis. Choose colors that align with
// your brand and provide adequate contrast among visual elements.
$color-primary: $palette-red-500 !default;
$color-primary-dark: $palette-red-700 !default;
$color-accent: $palette-pink-A200 !default;

// Our primary is dark, so use $color-dark-contrast for overlaid text.
$color-primary-contrast: $palette-green-700 !default;
// Our accent is dark, so use $color-dark-contrast for overlaid text.
$color-accent-contrast: $palette-green-700 !default;

Is it necessary to modify the source _variables.scss file in MDL?


For those working on customizing Material Design Color Palette:

I utilized angular-md-color.com/#/, which generates hex values formatted as an angular code block based on custom hex values.

(AngularJS code snippet)

You could also use a tool like HSL Color Picker to obtain corresponding color values (rgb, hsl) depending on the desired output format.

I have personally altered the Material Design Gray shade to match a Benjamin Moore Paint value requested by the client:

(Custom grey palette code snippet)

Now, I can easily apply the custom color scheme as required.

Answer №1

It appears, as per the MDL documentation, that one must "define variables before importing the default variables."

Therefore, the structure of MY _variables.scss is as follows:

@import "../../bower_components/material-design-lite/src/color-definitions";
//@import "functions";

$trim-color-classes: false !default;

// Emphasize color selection based on brand and component contrast.
$color-primary: $palette-grey-500 !default;
$color-primary-dark: $palette-grey-700 !default;
$color-accent: $palette-indigo-A200 !default;

// For dark primary and accent, use $color-dark-contrast for overlay text.
$color-primary-contrast: $palette-yellow-500 !default;
$color-accent-contrast: $palette-yellow-500 !default;

This file should be named prior to Bower including the material design component in my main.scss:

@import "common/_variables";

// Automatic Bower dependencies via wiredep (do not manually edit)
// bower:scss
@import "../../bower_components/material-design-lite/src/material-design-lite.scss";
// endbower

// additional import statements below

To display custom colors, the following code can be used within a page:

<div class="content-grid mdl-grid" style="height:300px">
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-50">
      50
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-100">
      100
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-200">
      200
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-300">
      300
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-400">
      400
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-500">
      500
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-600">
      600
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-700">
      700
    </div><div class="mdl-cell mdl-cell--1-col mdl-color--grey-A100">
      A100
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-A200">
      A200
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-A400">
      A400
    </div>
    <div class="mdl-cell mdl-cell--1-col mdl-color--grey-A700">
      A700
    </div>
</div>

https://i.sstatic.net/ze52a.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a navbar dropdown that is clickable on mobile devices and opens on hover on desktop is a simple way to improve

Utilizing Bootstrap 5 for my website creation, I am facing an issue with the navbar dropdown functionality. On mobile devices, the dropdown opens upon clicking but fails to close when clicked again. Meanwhile, on desktops, hovering over the dropdown works ...

Struggling with incorporating a Carousel feature while navigating through an array

I am struggling to properly implement a carousel using the data from my Videos Array. Instead of getting the desired output where videos should slide one by one, all the videos in the Array are being rendered at the same time. <div id="carouselEx ...

Issue with NodeJS proxy not functioning correctly

The current request route starts at localhost:3001, passes through a proxy located on the same localhost at localhost:3001/proxy, where it is then directed to the Salesforce instance. The ExpressJS proxy and AngularJS client-side app are utilized for this ...

What are the steps to create a downpour in every location on Earth

Is there a way to create a continuous raining effect for my weather app using CSS only? I have achieved a satisfactory look, but the rain effects seem to only cover random chunks of the screen rather than the entire screen. How can I make it cover the enti ...

Background image not adhering to the page width as expected within the Bootstrap framework

I feel like I'm losing my mind. Currently, I am in the process of designing a section that consists of four photo boxes - two at the top and two below. In order to achieve this layout, I have turned to utilizing Bootstrap. Unfortunately, this parti ...

Determine the dynamic height of content in a TypeScript file

Could you please provide guidance on obtaining the height of the content within this particular div element? For example, I need to calculate the dynamic height of the content. https://i.sstatic.net/2kNk3.png code .html <div class="margin-top-4 ...

Styling does not affect an Angular component that is injected into an iframe

I am facing an issue with styling in an iframe when trying to append my own angular component. Despite various attempts, I have been unsuccessful in getting the styling to apply to the component within the iframe. Upon loading the iframe, I use JavaScript ...

Tips for adding jQuery UI styling to elements generated dynamically

I have a challenge with generating text fields using jquery while applying jquery ui styling to the form. The issue is that the dynamically created elements do not inherit the css styles from jquery ui: let index = 0; $('#btn_generate').on(& ...

Troubleshooting AngularJS dependency injection problem on MacOSX

Hey everyone, I'm encountering this error message when attempting to run 'gulp serve-dev' in my codebase (https://github.com/CraigOldfield/AngularJSWork). The steps to reproduce are as follows: First, I cloned the repository onto my machin ...

Having trouble with displaying the logo on the navigation bar (using bootstrap and django)?

Hello, I am struggling to include a logo in my navbar and it's not being displayed. Despite researching similar queries from others, I still can't figure out why the image won't show up. I'm uncertain whether the issue lies within my co ...

Centered inline-block divisions

I've been coding for a number of years now, but I've recently started learning CSS. I'm currently facing an issue and need some help. I want to place two divs next to each other and center them. Here's the code I'm using: HTML: & ...

When the window is resized, the css('position') method may return undefined

Here is the code I am using to detect the browser resize event: window.onresize = function(){ var style = $('#button-selection').css('position'); if(style == "relative"){ $("#button-section").css("position"," "); }else if(style == ...

Changing between two images using HTML and CSS

I am currently designing a WordPress theme and I would like to create an effect where two different thumbnail images switch on hover. The code that I have come up with so far looks something like this : <a class="thumb" href="posturl"> <img src= ...

What is the best way to ensure items are aligned to the top of the navbar as a picture is enlarged?

I have searched through various similar questions, but none of them have provided a solution to my specific issue. I have attempted multiple suggestions, but none have been successful. (I am working with bootstrap4) Here is the html code I am using: < ...

Position the previous and next buttons next to the thumbnail images

I've implemented the cycle2 jQuery plugin on my website successfully, but I'm facing an issue with positioning the prev and next buttons next to my thumbnails. I want them to be aligned with the first and last thumbnail without relying on absolut ...

Checkbox radio buttons with mandatory selection

I'm facing a challenge with radio buttons in my form. While checkboxes could easily solve this issue, the customer specifically requested radio buttons. Here is the relevant section of the form: <label> <span>I Agree*</span> ...

Angular 10 encountering issues with loading Bootstrap styles

I'm currently working on a project that involves Angular 10 and the Bootstrap library. However, I'm encountering an issue where the Bootstrap styles are not loading properly. Upon checking the package.json file, I can see that Bootstrap is liste ...

What steps should I take to design a mobile-friendly navigation bar?

I have shared the code for my navigation bar in a previous post Fixing Nav Bar to top of page. Now, I want to create a mobile version of it, but I am new to designing for mobile devices. Based on feedback and some CSS tweaking, I have managed to make it wo ...

How can I make the navbar in Angular stay fixed in place?

After using the ng generate @angular/material:material-nav --name=home command to create a navbar, I am trying to make it fixed at the top while scrolling. I attempted using position: fixed; on my mat-sidenav-content but it didn't work. Does anyone ha ...

What is the reason behind div elements shifting when hovering over a particular element?

Currently, I have floated all my div elements (icons) to the left and margin-lefted them to create space in between. I've displayed them inline as well. However, when I hover over one element (icon), the rest of the elements move. Can you please help ...