New to Telerik UI for Blazor? Download free 30-day trial

How to Limit TextArea AutoSize and Show Scrollbar

Environment

Product TextArea for Blazor

Description

This KB article answers the following questions:

  • How to limit the TextArea auto size area and have a scrollbar when the component needs to expand more.
  • How to use the TextArea's AutoSize up to a point, and have a vertical scrollbar if the text grows beyond that.
  • How to make the TelerikTextArea show a scrollbar if a max height is hit.

Solution

  1. Set a Class to the TextArea.
  2. Apply a max-height style and overflow-y: auto !important; to the textarea children of the CSS class from the previous step.

AutoSize TextArea up to a maximum height

<TelerikTextArea @bind-Value="@TextValue"
                 Width="500px"
                 AutoSize="true"
                 Class="max-height-200" />

<style>
    .max-height-200 > textarea {
        max-height: 200px;
        overflow-y: auto !important;
    }
</style>

@code {
    private string TextValue { get; set; } = string.Empty;
}

See Also

In this article