New to Kendo UI for jQuery? Download free 30-day trial

MaskedTextBox Appearance

As of Kendo UI R1 2022, the MaskedTextBox widget uses brand new rendering.

In this article, you will find information about the new rendering of the Kendo UI MaskedTextBox.

For additional information regarding the decision behind these changes, visit the Rendering Components article.

For a live example, visit the Appearance Demo of the MaskedTextBox.

Options

The Kendo UI MaskedTextBox 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 MaskedTextBox 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

The following example demonstrates how to configure the size of the component through the widget configuration:

<input id="maskedtextbox" />
<script>
$("#maskedtextbox").kendoMaskedTextBox({
    mask: "000000",
    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-maskedtextbox k-input k-input-md">
</span>

Rounded

The rounded option controls how much border radius is applied to the rendered MaskedTextBox. 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

The following example demonstrates how to configure the rounded of the component through the widget configuration:

<input id="maskedtextbox" />
<script>
$("#maskedtextbox").kendoMaskedTextBox({
    mask: "000000",
    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-maskedtextbox k-input k-rounded-md">
</span>

FillMode

The fillMode option controls the way the color is applied to the rendered MaskedTextBox. The structure of the class is k-input-{fillMode}.

The following values are available for the fillMode option:

  • solid
  • flat
  • outline

The following example demonstrates how to configure the size of the component through the widget configuration:

<input id="maskedtextbox" />
<script>
$("#maskedtextbox").kendoMaskedTextBox({
    mask: "000000",
    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-maskedtextbox k-input k-input-solid">
</span>

Old vs New Rendering

The old rendering of the component consisted of a wrapping span element with a child input element.

<span class="k-maskedtextbox">
    <input class="k-textbox" />
</span>

The new rendering of the component also consists of a wrapping span element with a child input element. The major change are the CSS classes that are applied to the two elements:

  • The span element controls the overall appearance of the widget and has the following class structure:

    <span class="k-maskedtextbox k-input k-input-md k-rounded-md k-input-solid">
    </span>
    
  • The input element controls the appearance of the MaskedTextBox itself and has the following class structure:

    <input type="text" class="k-input-inner" value="..." placeholder="..." />
    

The following example demonstrates how to configure the appearance of the component through the widget configuration:

<input id="maskedtextbox" />
<script>
$("#maskedtextbox").kendoMaskedTextBox({
    mask: "000000",
    size: "medium",
    rounded: "medium",
    fillMode: "solid"
});
</script>

The full rendering of the component has the following HTML structure:

<span class="k-maskedtextbox k-input k-input-md k-rounded-md k-input-solid">
  <input type="text" class="k-input-inner" value="..." placeholder="..." />
</span>

Visual Backwards Compatibility

In order to achieve the same look and feel as the old rendering, the element references must be updated. Visit the CSS Classes Migration and JQuery Selectors Migration sections of the Styling Overview article for additional information.

The new styling and rendering supports only the default options when you use a LESS theme.

Previously, a reference to the MaskedTextBox element was obtainable through the k-textbox class.

$(".k-textbox") // Returns a reference to the input element in the old rendering.

With the new rendering, the MaskedTextBox element must be targeted by using the k-input-inner class.

$(".k-input-inner") // Returns a reference to the input element in the new rendering.

See Also

In this article