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

AutoComplete Appearance

As of the R1 2022 release, the AutoComplete component uses a new rendering. To learn more about the reasons for this decision, see the Components Appearance article.

For a live example of the AutoComplete styling options, visit the AutoComplete Appearance Demo.

Options

The AutoComplete 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 the size of the AutoComplete. The k-input-{size} class, which is applied to the wrapping span element of the AutoComplete, reflects the value of the Size option.

The following values are available for the Size option:

  • Small—small size (applies the k-input-sm class to the wrapping span element).
  • Medium—medium size (applies the k-input-md class to the wrapping span element).
  • Large—large size (applies the k-input-lg class to the wrapping span element).

The following example demonstrates how to set Size in the declaration of the AutoComplete:

    @(Html.Kendo().AutoComplete()
            .Name("input")
            .Size(ComponentSize.Medium)
            .BindTo(new string[]
            {
                "Red-violet",
                "Red",
                "Red-orange",
                "Orange",
                "Yellow-orange",
                "Yellow",
                "Yellow-green",
                "Green",
                "Blue-green",
                "Blue",
                "Blue-violet",
                "Violet"
            })
            .HtmlAttributes(new { style = "width:100%;" })
    )
@{
    var Colors = new string[]
            {
                "Red-violet",
                "Red",
                "Red-orange",
                "Orange",
                "Yellow-orange",
                "Yellow",
                "Yellow-green",
                "Green",
                "Blue-green",
                "Blue",
                "Blue-violet",
                "Violet"
            };
}
<kendo-autocomplete name="input"
                    size="ComponentSize.Medium"
                    bind-to="Colors"
                    style="width:100%">

</kendo-autocomplete>

The default Size value is Medium and it is applied to the wrapping span element through the k-input-md class.

<span class="k-autocomplete k-input k-input-md">
</span>

Rounded

The Rounded option controls the border radius of the AutoComplete. The class that corresponds to the Rounded option is k-rounded-{rounded}.

The following values are available for the Rounded option:

  • Small—small border radius (applies the k-rounded-sm class to the wrapping span element).
  • Medium—medium border radius (applies the k-rounded-md class to the wrapping span element).
  • Large—large border radius (applies the k-rounded-lg class to the wrapping span element).
  • Full—largest border radius (applies the k-rounded-full class to the wrapping span element).

The following example demonstrates how to set Rounded in the declaration of the AutoComplete:

    @(Html.Kendo().AutoComplete()
            .Name("input")
            .Rounded(Rounded.Medium)
            .BindTo(new string[]
            {
                "Red-violet",
                "Red",
                "Red-orange",
                "Orange",
                "Yellow-orange",
                "Yellow",
                "Yellow-green",
                "Green",
                "Blue-green",
                "Blue",
                "Blue-violet",
                "Violet"
            })
            .HtmlAttributes(new { style = "width:100%;" })
    )
@{
    var Colors = new string[]
            {
                "Red-violet",
                "Red",
                "Red-orange",
                "Orange",
                "Yellow-orange",
                "Yellow",
                "Yellow-green",
                "Green",
                "Blue-green",
                "Blue",
                "Blue-violet",
                "Violet"
            };
}
<kendo-autocomplete name="input"
                    rounded="Rounded.Medium"
                    bind-to="Colors"
                    style="width:100%">

</kendo-autocomplete>

The default Rounded value is Medium and it is applied to the wrapping span element through the k-rounded-md class.

<span class="k-autocomplete k-input k-rounded-md">
</span>

FillMode

The FillMode option controls the way color is applied to the rendered AutoComplete. The k-input-{fillMode} class, which is applied to the wrapping span element of the AutoComplete, reflects the value of the FillMode option.

The following values are available for the FillMode option:

  • Solid—applies the k-input-solid class to the wrapping span element.
  • Flat—applies the k-input-flat class to the wrapping span element.
  • Outline—applies the k-input-outline class to the wrapping span element.

The following example demonstrates how to set FillMode in the declaration of the AutoComplete:

    @(Html.Kendo().AutoComplete()
            .Name("input")
            .FillMode(FillMode.Solid)
            .BindTo(new string[]
            {
                "Red-violet",
                "Red",
                "Red-orange",
                "Orange",
                "Yellow-orange",
                "Yellow",
                "Yellow-green",
                "Green",
                "Blue-green",
                "Blue",
                "Blue-violet",
                "Violet"
            })
            .HtmlAttributes(new { style = "width:100%;" })
    )
@{
    var Colors = new string[]
            {
                "Red-violet",
                "Red",
                "Red-orange",
                "Orange",
                "Yellow-orange",
                "Yellow",
                "Yellow-green",
                "Green",
                "Blue-green",
                "Blue",
                "Blue-violet",
                "Violet"
            };
}
<kendo-autocomplete name="input"
                    fill-mode="FillMode.Solid"
                    bind-to="Colors"
                    style="width:100%">

</kendo-autocomplete>

The default FillMode value is Solid and it is applied to the wrapping span element through the k-input-solid class.

<span class="k-autocomplete k-input k-input-solid">
</span>

Old vs New Rendering

Below you will find the differences between the old and the new rendering.

Wrapper Rendering:

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

Popup rendering without virtualization:

<div class="k-list-container k-popup k-group k-reset k-state-border-up" id="products-list" data-role="popup">
    [Header template]
    <div class="k-group-header">Argentina</div>
    <div class="k-list-scroller">
      <ul class="k-list k-reset">
        <li class="k-item">Patricio Simpson</li>
        ...
        <li class="k-item k-first"> 
            Ann Devon 
            <div class="k-group">UK</div>
        </li>
      </ul>
    </div>
    <div class="k-nodata">
      <div>No Data!</div>
    </div>
    <div class="k-footer"> 
      [Footer template]
    </div>
</div>
<div class="k-popup k-group k-reset">
    <div class="k-list k-list-md">
        <div class="k-list-header">
            [header template]
        </div>
        <div class="k-list-group-sticky-header">Argentina</div>
        <div class="k-list-content k-list-scroller">
            <ul class="k-list-ul">
                <li class="k-list-item">
                    <span class="k-list-item-text">Patricio Simpson</span>
                </li>
                ...
                <li class="k-list-item k-first">
                    <span class="k-list-item-text">Roland Mendel</span>
                    <div class="k-list-item-group-label">Austria</div>
                </li>
                ...
            </ul>
        </div>
        <div class="k-nodata">
            <div>No data found.</div>
        </div>
        <div class="k-list-footer">
            [Footer template]
        </div>
    </div>
</div>

Popup rendering with virtualization:

<div class="k-list-container k-popup k-group k-reset">
    <div>
       [Header template]
    </div>
    <div class="k-virtual-wrap">
        <div class="k-group-header"></div>
        <div class="k-virtual-content">
          <ul class="k-list k-reset k-virtual-list">
            <li class="k-virtual-item k-item">
              Vins et alcools Chevalier
            </li>
            ...
            <li class="k-virtual-item k-item">
              Toms Spezialitäten
            </li>
            ...
          </ul>
          <div class="k-height-container">
            <div style="height: ....;"></div>
          </div>
        </div>
    </div>
    <div class="k-nodata">
        <div>No data found.</div>
    </div>
    <div class="k-footer">
        [Footer template]
    </div>
</div>
<div class="k-popup k-group k-reset">
    <div class="k-list k-list-md k-virtual-list">
        <div class="k-list-header">
            [Header template]
        </div>
        <div class="k-list-group-sticky-header">Argentina</div>
        <div class="k-list-content k-virtual-content">
            <ul class="k-list-ul">
                <li class="k-list-item">
                    <span class="k-list-item-text">
                        Text
                    </span>
                </li>
                ...
                <li class="k-list-item k-first">
                    <span class="k-list-item-text">
                        Ernst Handel, Austria 
                    </span>
                    <div class="k-list-item-group-label">Austria</div>
                </li>
                ...
            </ul>
            <div class="k-height-container">
                <div style="height: ...;"></div>
            </div>
        </div>
        <div class="k-nodata">
            <div>No data found.</div>
        </div>
        <div class="k-list-footer">
            [Footer template]
        </div>
    </div>
</div>

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 AutoComplete 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, the AutoComplete input 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