Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default body color of materialize datetimepicker?

You can find the entire code here http://codepen.io/anon/pen/BjqxOq

I am displaying a login form using Materialize CSS which you can see in the above Codepen. It has two buttons Login and Register. When Register is clicked a modal is displayed containing necessary registration fields and one of it is materialize datetimepicker.

Is there a possibility to change the default body color of datetimepicker?

HTML

<div class="row">
    <div class="input-field col s6">Date of Birth
        <input type="date" class="datepicker ">
    </div>
</div>

JS

$(document).ready(function(){
    $('.datepicker').pickadate({
        selectMonths: true, // Creates a dropdown to control month
        selectYears: 15 // Creates a dropdown of 15 years to control year
    });
});
like image 408
jackD Avatar asked Feb 06 '16 21:02

jackD


3 Answers

I have noticed that some answers are not working I have searched a bit and this is the result. Change your CSS file according to this. I have added all the text below feel free to copy.

Hope it helps...

.picker__date-display { background-color: #6d4e7a; }
.picker__day.picker__day--today { color: red; }
.picker__day--selected, .picker__day--selected:hover, .picker--focused .picker__day--selected { background-color: #6d4e7a;}
.picker__close { color: #6d4e7a !important;}
.picker__today { color: #6d4e7a !important;}
.clockpicker-tick:hover { background: #6d4e7a !important; }
.clockpicker-canvas line { stroke: #6d4e7a !important; }
.clockpicker-canvas-bearing { fill: #6d4e7a !important; }
.clockpicker-canvas-bg { fill: #6d4e7a !important; }

enter image description here

like image 93
Adi Azarya Avatar answered Nov 13 '22 18:11

Adi Azarya


The materializecss datepicker has a div with a class called "picker__box". If you set the background-color for this class, your datepicker will assume this color, as you can see in below codepen.

http://codepen.io/anon/pen/OMBoMz

.picker__box{
    background-color: #CCC;
}

EDIT

To change the upper half body color too, you have to set background-color for two more classes:

.picker__date-display, .picker__weekday-display{
    background-color: #CCC;
}

I hope this helps!

like image 36
Allan Pereira Avatar answered Nov 13 '22 17:11

Allan Pereira


EDIT: This doesn't change the body, but everything but the body, and let the body white

Cant comment.

Allan Pereira solution didn't work for me, everything went to my color (even the white-background).

I used this

    .picker__date-display, .picker__weekday-display{
        background-color: rgba(66, 133, 244, 0.79);
    }

    div.picker__day.picker__day--infocus.picker__day--selected.picker__day--highlighted {
        background-color: rgba(66, 133, 244, 0.79);
    }

    button.picker__today, button.picker__close {
        color: rgba(66, 133, 244, 0.79);
    }

(color is a nice blue)

edit: codepen: http://codepen.io/anon/pen/Kgxbdj#anon-signup

like image 30
JeanFoin Avatar answered Nov 13 '22 16:11

JeanFoin