DateTimePicker Appearance
As of Kendo UI R1 2022, the DateTimePicker widget uses brand new rendering.
In this article, you will find information about the new rendering of the Kendo UI DateTimePicker.
For additional information regarding the decision behind these changes, visit the Styling Overview article.
For a live example, visit the Appearance Demo of the DateTimePicker.
Options
The Kendo UI DateTimePicker supports the following styling options:
-
size
—configures the overall size of the component. -
rounded
—configures the border radius of the component. -
fillMode
—configures how the color is applied to the component.
Size
The size
option controls how big or small the rendered DateTimePicker looks. The structure of the class is k-input-{size}
.
The following values are available for the size
option:
-
sm
—small size -
md
—medium size -
lg
—large size -
none
—unset
The following example demonstrates how to configure the size
of the component through the widget configuration:
<input id="datetimepicker" />
<script>
$("#datetimepicker").kendoDateTimePicker({
size: "medium"
});
</script>
The default size value is medium
and it is applied to the wrapping span element through the k-input-md
class.
<span class="k-datetimepicker k-input k-input-md">
</span>
Rounded
The rounded
option controls how much border radius is applied to the rendered DateTimePicker. The structure of the class is k-rounded-{size}
.
The following values are available for the rounded
option:
-
sm
—small border radius -
md
—medium border radius -
lg
—large border radius -
full
—largest border radius -
none
—unset
The following example demonstrates how to configure the rounded
of the component through the widget configuration:
<input id="datetimepicker" />
<script>
$("#datetimepicker").kendoDateTimePicker({
rounded: "medium"
});
</script>
The default rounded value is medium
and it is applied to the wrapping span element through the k-rounded-md
class.
<span class="k-datetimepicker k-input k-rounded-md">
</span>
FillMode
The fillMode
option controls the way the color is applied to the rendered DateTimePicker. The structure of the class is k-input-{fillMode}
.
The following values are available for the fillMode
option:
solid
flat
outline
none
The following example demonstrates how to configure the size
of the component through the widget configuration:
<input id="datetimepicker" />
<script>
$("#datetimepicker").kendoDateTimePicker({
fillMode: "solid"
});
</script>
The default fillMode value is solid
and it is applied to the wrapping span element through the k-input-solid
class.
<span class="k-datetimepicker k-input k-input-solid">
</span>
Old vs New Rendering
The old rendering of the component consisted of several wrapping elements:
-
The outer
span
wrapper with thek-datetimepicker
andk-widget
classes.<span class="k-widget k-datetimepicker"> </span>
-
The inner
span
wrapper with thek-picker-wrap
class.<span class="k-picker-wrap k-state-default"> </span>
-
The
input
element with thek-input
class. This element is a child of thek-picker-wrap
span.<input class="k-input" />
-
The
span
wrapper with thek-select
class. This element is a child of thek-picker-wrap
span and parent of thebutton
elements.<span unselectable="on" class="k-select"> </span>
-
The date button
span
element with thek-link-date
class. This element is a child of thek-select
span and renders the button which expands the date picker on click.<span class="k-link k-link-date" role="button"> </span>
-
The time button
span
element with thek-link-time
class. This element is a child of thek-select
span and renders the button which expands the time picker on click.<span class="k-link k-link-time" role="button"> </span>
-
The icon
span
element with thek-i-calendar
class. This element is a child of thek-link-date
button and renders the calendar icon.<span class="k-icon k-i-calendar">
-
The icon
span
element with thek-i-clock
class. This element is a child of thek-link-time
button and renders the clock icon.<span class="k-icon k-i-clock">
The following example demonstrates the full version of the old rendering:
<span class="k-widget k-datetimepicker" style="width: 100%;">
<span class="k-picker-wrap k-state-default">
<input class="k-input" >
<span class="k-icon k-i-warning k-hidden"></span>
<span unselectable="on" class="k-select">
<span class="k-link k-link-date" role="button">
<span unselectable="on" class="k-icon k-i-calendar"></span>
</span>
<span class="k-link k-link-time" role="button">
<span unselectable="on" class="k-icon k-i-clock"></span>
</span>
</span>
</span>
</span>
The new rendering of the component consists of a single wrapping span
element that contains the child input
and button
elements:
-
The
span
element controls the overall appearance of the widget and has the following class structure:<span class="k-datetimepicker k-input k-input-md k-rounded-md k-input-solid"> </span>
-
The
input
element controls the appearance of the DateTimePicker itself and has the following class structure:<input type="text" class="k-input-inner" value="..." placeholder="..." />
-
The
button
elements control the appearance of the buttons that expand the date and time pickers:<button type="button" class="k-input-button k-button k-icon-button k-button-md k-button-solid k-button-solid-base"> </button>
-
The inner
span
elements of each of the buttons render the calendar and clock icons:<span class="k-button-icon k-icon k-i-clock"></span> <span class="k-button-icon k-icon k-i-calendar"></span>
The following example demonstrates how to configure the appearance of the component through the widget configuration:
<input id="datetimepicker" />
<script>
$("#datetimepicker").kendoDateTimePicker({
size: "medium",
rounded: "medium",
fillMode: "solid"
});
</script>
The following example demonstrates the full version of the new rendering:
<span class="k-datetimepicker k-input k-input-md k-rounded-md k-input-solid">
<input type="text" class="k-input-inner" value="..." placeholder="..." />
<button type="button" class="k-input-button k-button k-icon-button k-button-md k-button-solid k-button-solid-base">
<span class="k-button-icon k-icon k-i-clock"></span>
</button>
<button type="button" class="k-input-button k-button k-icon-button k-button-md k-button-solid k-button-solid-base">
<span class="k-button-icon k-icon k-i-calendar"></span>
</button>
</span>
Visual Backwards Compatibility
To achieve the same look and feel as the old rendering, you must update the element references.
When you use a LESS theme, the new styling and rendering supports only the default options.
Previously, a reference to the DateTimePicker input element was obtainable through the k-input
class.
$(".k-input") // Returns a reference to the input element in the old rendering.
With the new rendering, you must target the DateTimePicker input element by using the k-input-inner
class.
$(".k-input-inner") // Returns a reference to the input element in the new rendering.
Previously, a reference to the date and time button elements was obtainable through the k-link-date
and k-link-time
classes respectively.
$(".k-link-date") // Returns a reference to the date button element in the old rendering.
$(".k-link-time") // Returns a reference to the time button element in the old rendering.
With the new rendering, you can obtain a reference to the date and time button elements through the k-button
class.
$(".k-button:eq(0)") // Returns a reference to the date button element in the new rendering.
$(".k-button:eq(1)") // Returns a reference to the time button element in the new rendering.
The following example showcases how to change the background colors of the input and button elements of the DateTimePicker in both the new, and the old rendering:
<!-- Open the example in Dojo and select version prior to 2022 R1 to see the difference in the appearance -->
<div id="parent">
<input id="datetimepicker" />
</div>
<style>
/* Doesn't work AFTER R1 2022 */
#parent .k-input {
background-color: #0071bc !important; /* Blue color in versions BEFORE R1 2022 */
}
#parent .k-link-date {
background-color: red; /* Applies red color to the date button element BEFORE R1 2022 */
}
#parent .k-link-time {
background-color: cyan; /* Applies cyan color to the time button element BEFORE R1 2022 */
}
/* Doesn't work BEFORE R1 2022 */
#parent .k-input-inner {
background-color: #2e8540 !important; /* Green color in versions AFTER R1 2022 */
}
#parent .k-input-button:nth-of-type(1) {
background-color: yellow; /* Applies yellow color to the date button element AFTER R1 2022 */
}
#parent .k-input-button:nth-of-type(2) {
background-color: orange; /* Applies yellow color to the time button element AFTER R1 2022 */
}
</style>
<script>
$("#datetimepicker").kendoDateTimePicker();
</script>
Change the Order of the Time and Calendar Buttons
With the new rendering, the time button appears before the calendar button. To reverse this change, use the jQuery.insertAfter method:
<input id="datetimepicker" />
<script>
$(document).ready(function () {
$("#datetimepicker").kendoDateTimePicker();
$(".k-datetimepicker .k-button:first").insertAfter($(".k-datetimepicker .k-button:last"));
});
</script>