New to Telerik UI for ASP.NET Core? Download free 30-day trial

Prefix and Suffix

The TextBox component provides options for enhancing the user interface interactivity by adding custom content as prefix and suffix adornments.

The prefix and suffix input adornments are elements positioned before and after the TextBox input element, commonly used to clarify the expected data in the input, such as currency symbols or unit indicators, and provide direct functionality for the entered data, like password visibility toggles, formatting, and more.

Prefix

The prefix input adornment is placed before the TextBox field and provides an additional context that guides users in entering specific data, such as icons for currencies or unit indicators. To configure the Prefix functionality, use the PrefixOptions() configuration, which facilitates the following options:

  • Icon()—Inserts an icon before the TextBox element. The option accepts the name of an existing icon in the Kendo UI theme or SVG content.
  • Template()—Adds custom content before the TextBox element. You can use a variety of templating options like TemplateId(), TemplateHandler(), and more.
  • Separator()—By default, the separator is visible. Disable the Separator() option to remove the default separator of the prefix content.

The following example demonstrates how to add an icon as a prefix of the TextBox.

    @(Html.Kendo().TextBox()
        .Name("email")
        .Placeholder("Enter your email...")
        .PrefixOptions(prefix => prefix.Icon("envelop"))
        .HtmlAttributes(new { style = "width: 100%" })
    )
    <kendo-textbox name="email" placeholder="Enter your email..." style="width: 100%">
        <prefix-options icon="envelop" />
    </kendo-textbox>

Suffix

The suffix input adornment is an element positioned after the input field. Usually, it offers direct functionality related to the entered data, such as toggles for password visibility, formatting options, or the ability to clear the input. Set up the Suffix functionality through the SuffixOptions() configuration that provides the following options:

  • Icon()—Adds an icon after the TextBox element. The option accepts the name of an existing icon in the Kendo UI theme or SVG content.
  • Template()—Adds custom content for the suffix adornment of the TextBox.
  • Separator()—By default, the separator is visible. Disable the Separator() option to remove the default separator of the suffix content.

The following example demonstrates how to insert a button after the TextBox element through the TemplateId() option.

    <script type="text/x-kendo-template" id="suffixTemplate">
        @(Html.Kendo().Button()
            .Name("suffix-send-button")
            .Icon("paper-plane")
            .FillMode(ButtonFillMode.Flat)
            .ToClientTemplate()
        )
    </script>

    @(Html.Kendo().TextBox()
        .Name("email")
        .Placeholder("Enter your email...")
        .SuffixOptions(suffix => suffix.TemplateId("suffixTemplate"))
        .HtmlAttributes(new { style = "width: 100%" })
    )
    <script type="text/html" id="suffixTemplate">
        <kendo-button name="suffix-send-button" is-in-client-template="true"
            icon="paper-plane"
            fill-mode="ButtonFillMode.Flat">
        </kendo-button>
    </script>

    <kendo-textbox name="email" placeholder="Enter your email..." style="width: 100%">
        <suffix-options template-id="suffixTemplate" />
    </kendo-textbox>

See Also

In this article