alexa
menu

Blazor Toolkit

    Show / Hide Table of Contents

    Class SfTextArea

    The TextArea is a multiline text input element that allows users to enter and edit multi-line text content with advanced features like resizing, floating labels, and validation.

    Inheritance
    System.Object
    SfBaseComponent
    SfInputBase<System.String>
    SfTextArea
    Implements
    System.IAsyncDisposable
    Inherited Members
    SfBaseComponent.DisposeAsync()
    SfInputBase<String>.CssClass
    SfInputBase<String>.Disabled
    SfInputBase<String>.EnablePersistence
    SfInputBase<String>.ID
    SfInputBase<String>.ValidateOnInput
    SfInputBase<String>.Value
    SfInputBase<String>.ValueChanged
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.APPEND
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.APPENDICON
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ARIADISABLED
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseAutocomplete
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseFloatLabelType
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseHtmlAttributes
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseInputAttributes
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseIsReadOnlyInput
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BasePlaceholder
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseReadOnly
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseShowClearButton
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseTabIndex
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BaseWidth
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.BlurHandlerAsync(System.String, System.Boolean)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ChangeHandlerAsync(Microsoft.AspNetCore.Components.ChangeEventArgs)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ChildContent
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.CLEARICON
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.CLEARICONHIDE
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ClickStopPropagation
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ComponentReference
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ContainerAttributes
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ContainerClass
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ContainerHtmlAttributes
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.CONTROLCONTAINER
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.CONTROLOLDCONTAINER
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DataId
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DECREMENT
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DECREMENTHEADING
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DecrementTitle
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DISABLE
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DISABLEDATTRIBUTE
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DISABLEICON
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.DisposeAsyncCore()
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FLOATINPUT
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FloatLabel
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FLOATLABELBOTTOM
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FLOATLABELTOP
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FLOATTEXT
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FocusHandlerAsync(Microsoft.AspNetCore.Components.Web.FocusEventArgs)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FocusOutHandlerAsync(Microsoft.AspNetCore.Components.Web.FocusEventArgs)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FormatValue(System.String)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.FormatValueAsString(System.String)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.GROUPICON
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.INCREMENT
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.INCREMENTHEADING
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.IncrementTitle
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.INPUT
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.INPUTBASECLASS
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.InputEditContext
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.INPUTFOCUS
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.INPUTGROUP
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.InputHandlerAsync(Microsoft.AspNetCore.Components.ChangeEventArgs)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.InputHtmlAttributes
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.IsBindInputEvent
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.IsClearButtonClicked
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.IsFocused
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.IsValueTemplate
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ListOfButtons
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.MouseDownSpinnerPrevent
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.MULTILINE
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.MultilineInput
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnAfterRenderAsync(System.Boolean)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnChange
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnChangeHandlerAsync(Microsoft.AspNetCore.Components.ChangeEventArgs)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnInitializedAsync()
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnInputHandlerAsync(Microsoft.AspNetCore.Components.ChangeEventArgs)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnParametersSetAsync()
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnPaste
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.OnPasteHandlerAsync(Microsoft.AspNetCore.Components.Web.ClipboardEventArgs)
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.PREPEND
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.PREPENDICON
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.PreventIconHandler
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.RootClass
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.SetEnabled()
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.SPACE
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.SpinButton
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.SPINDOWN
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.SPINUP
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.ValueExpression
    Syncfusion.Blazor.Toolkit.Inputs.SfInputBase<System.String>.WireClearBtnEventsAsync()
    Namespace: Syncfusion.Blazor.Toolkit.Inputs
    Assembly: Syncfusion.Blazor.Toolkit.dll
    Syntax
    public class SfTextArea : SfInputBase<string>, IAsyncDisposable
    Remarks

    The SfTextArea component provides a rich multiline text input experience with support for floating labels, clear buttons, validation, resizing options, and various input modes. It extends the base input functionality to handle multiline text scenarios effectively.

    Examples

    A basic TextArea component.

    <SfTextArea @bind-Value="@textValue" 
                Placeholder="Enter your message..."
                RowCount="4"
                ColumnCount="50"
                MaxLength="500"
                ResizeMode="Resize.Both">
    </SfTextArea>
    
    @code {
        private string textValue = string.Empty;
    }

    Constructors

    SfTextArea()

    Declaration
    public SfTextArea()

    Properties

    ColumnCount

    Gets or sets the number of columns for the SfTextArea component.

    Declaration
    public int ColumnCount { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer representing the number of columns. The default value is 20.

    Remarks

    The ColumnCount property specifies the visible width of the SfTextArea, measured in average character widths. This property is only effective when the Width property is not set. If both ColumnCount and Width are specified, the Width property takes precedence.

    Examples
    <SfTextArea ColumnCount="30" RowCount="4" Placeholder="Enter text"></SfTextArea>

    Created

    Gets or sets the event callback that will be invoked when the SfTextArea component is created.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the SfTextArea component is successfully created and initialized. The callback receives an object parameter.

    Remarks

    The Created event is triggered once during the component lifecycle, immediately after the SfTextArea component has been rendered and initialized in the DOM. This event is useful for performing initialization tasks, setting up event handlers, or executing code that depends on the component being fully created.

    Examples
    <SfTextArea @ref="textAreaRef" Placeholder="Enter your text" 
                Created="@OnTextAreaCreated"></SfTextArea>
    
    @code {
        SfTextArea? textAreaRef;
        private string creationStatus = string.Empty;
        private async Task OnTextAreaCreated(object args)
        {
            // Component is now fully initialized
            creationStatus = "TextArea component created successfully";
        }
    }

    Destroyed

    Gets or sets the event callback that will be invoked when the SfTextArea component is destroyed.

    Declaration
    public EventCallback<object> Destroyed { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the SfTextArea component is being destroyed or removed from the DOM. The callback receives an object parameter.

    Remarks

    The Destroyed event is triggered during the component cleanup phase, before the SfTextArea component is removed from the DOM. This event is useful for performing cleanup operations, disposing resources, removing event handlers, or executing code that should run when the component is being destroyed.

    Examples
    <SfTextArea @ref="textAreaRef" Placeholder="Enter your text" 
                Destroyed="@OnTextAreaDestroyed"></SfTextArea>
    <p>@destructionMessage</p>
    @code {
        SfTextArea? textAreaRef;
        private string destructionMessage = string.Empty;
        private async Task OnTextAreaDestroyed(object args)
        {
            // Perform cleanup operations
            destructionMessage = "TextArea component is being destroyed";
        }
    }

    FloatLabelType

    Gets or sets the floating label behavior of the SfTextArea. The Placeholder text acts as a label.

    Declaration
    public FloatLabelType FloatLabelType { get; set; }
    Property Value
    Type Description
    FloatLabelType

    One of the FloatLabelType enumeration. The default value is Never.

    Remarks
    • If the FloatLabelType is Never, the placeholder text does not float as a label.
    • If the FloatLabelType is Auto, the placeholder text will float above the SfTextArea component as a label after focusing on it.
    • If the FloatLabelType is Always, the placeholder text is displayed as a label above the SfTextArea component.
    Examples

    In the following code example, set the float label as Auto.

     
      <SfTextArea FloatLabelType="FloatLabelType.Auto" Placeholder="Enter a value"></SfTextArea> 

    HtmlAttributes

    Gets or sets a collection of additional attributes such as styles, class, and more that will be applied to the SfTextArea component.

    Declaration
    public Dictionary<string, object> HtmlAttributes { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.Dictionary<System.String, System.Object>

    The value as a dictionary collection. The default value is null.

    Remarks

    If you configure both the property and equivalent HTML attributes, the component considers the property value.

    Examples
     
    <SfTextArea HtmlAttributes="@CustomAttribute"> 
    </SfTextArea> 
    @code{ 
        Dictionary<string, object> CustomAttribute = new Dictionary<string, object>() 
        { 
            { "title", "Enter your text" } 
        }; 
    } 

    InputAttributes

    Gets or sets a collection of additional input attributes such as disabled, value, and more that will be applied to the SfTextArea component.

    Declaration
    public Dictionary<string, object> InputAttributes { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.Dictionary<System.String, System.Object>

    A dictionary collection containing additional input attributes. The default value is an empty dictionary.

    Remarks

    Additional attributes can be added by specifying them as inline attributes or by using the @attributes directive. If you configure both a property and its equivalent HTML attribute, the component considers the property value over the HTML attribute. This property captures unmatched HTML attributes that are not explicitly defined as component parameters.

    Examples
    <SfTextArea Placeholder="Enter your Name" @attributes="@CustomAttribute">
    </SfTextArea>
    @code{
        Dictionary<string, object> CustomAttribute = new Dictionary<string, object>()
        {
            { "maxlength", "4" }
        };
    }

    MaxLength

    Gets or sets the maximum number of characters allowed in the SfTextArea.

    Declaration
    public int MaxLength { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer representing the maximum number of characters. The default value is -1, indicating no maximum limit.

    Remarks

    Set this property to impose a maximum limit on the number of characters that can be entered into the SfTextArea. A value of -1 indicates no maximum limit, allowing unlimited text input. When the maximum length is reached, users will not be able to type additional characters.

    Examples
     
    <SfTextArea MaxLength="100" Placeholder="Enter text"></SfTextArea> 

    OnBlur

    Gets or sets the event callback that will be invoked when the SfTextArea loses focus.

    Declaration
    public EventCallback<TextAreaFocusOutEventArgs> OnBlur { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<TextAreaFocusOutEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the SfTextArea loses focus. The callback receives a TextAreaFocusOutEventArgs containing blur-related information.

    Remarks

    The OnBlur event is triggered when the user clicks outside the SfTextArea, tabs away from it, or programmatically removes focus from the component. This event is commonly used for validation purposes, saving draft content, hiding input-specific UI elements, or updating the application state when the user finishes interacting with the textarea. The event provides information about the blur operation through the TextAreaFocusOutEventArgs parameter.

    Examples
    <SfTextArea @ref="textAreaRef" Placeholder="Enter your message"
                OnBlur="@OnTextAreaBlur" MaxLength="200"></SfTextArea>
    <span>@validationMessage</span>
    @code {
        SfTextArea? textAreaRef;
        private string validationMessage = string.Empty;
        private void OnTextAreaBlur(TextAreaFocusOutEventArgs args)
        {
            // Perform validation on blur
            if (string.IsNullOrEmpty(args.Value))
            {
                validationMessage = "This field is required";
            }
        }
    }

    OnFocus

    Gets or sets the event callback that will be invoked when the SfTextArea gets focus.

    Declaration
    public EventCallback<TextAreaFocusInEventArgs> OnFocus { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<TextAreaFocusInEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the SfTextArea receives focus. The callback receives a TextAreaFocusInEventArgs containing focus-related information.

    Remarks

    The OnFocus event is triggered when the user clicks on the SfTextArea, tabs to it, or programmatically sets focus to the component. This event is useful for performing actions when the textarea becomes active, such as highlighting the input area, showing validation messages, or updating the UI state. The event provides information about the focus operation through the TextAreaFocusInEventArgs parameter.

    Examples
    <SfTextArea @ref="textAreaRef" Placeholder="Enter your text"
                OnFocus="@OnTextAreaFocus"></SfTextArea>
    
    @code {
        SfTextArea? textAreaRef;
        private string focusMessage = string.Empty;
    
        private void OnTextAreaFocus(TextAreaFocusInEventArgs args)
        {
            focusMessage = $"TextArea focused with value: {args.Value ?? "empty"}";
        }
    }

    OnInput

    Gets or sets the event callback that will be invoked when the user types or pastes text into the SfTextArea.

    Declaration
    public EventCallback<TextAreaInputEventArgs> OnInput { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<TextAreaInputEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked on each input action within the SfTextArea. The callback receives a TextAreaInputEventArgs containing the current input value and related event details.

    Remarks

    The OnInput event is triggered whenever the user interacts with the SfTextArea by typing, pasting, or using any input method to modify the content. It provides real-time updates as the user enters text, allowing you to perform actions or validation based on the changing input.

    It is important to note that the OnInput event may fire frequently during user input, potentially with each keystroke, so it is generally suitable for handling real-time updates or feedback rather than more intensive processing.

    Examples
    <SfTextArea Placeholder="Enter a value" OnInput="@OnInput">
    </SfTextArea>
    @code{
        private void OnInput(TextAreaInputEventArgs args)
        {
            var TextValue = args.Value;
        }
    }

    Placeholder

    Gets or sets the text that is shown as a hint or placeholder until the user focuses on the SfTextArea.

    Declaration
    public string Placeholder { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the placeholder text. The default value is null.

    Remarks

    The Placeholder property specifies the text that appears in the SfTextArea when it is empty, providing a hint to the user about the expected input.

    Examples
     
    <SfTextArea Placeholder="Enter text" RowCount="4"></SfTextArea> 

    ReadOnly

    Gets or sets a value indicating whether the SfTextArea is read-only.

    Declaration
    public bool ReadOnly { get; set; }
    Property Value
    Type Description
    System.Boolean

    A boolean indicating whether the SfTextArea is read-only. The default value is false.

    Remarks

    Set this property to true to make the SfTextArea read-only, preventing user input.

    Examples
     
    <SfTextArea ReadOnly="true" Placeholder="Read-only text" RowCount="4"></SfTextArea> 

    ResizeMode

    Gets or sets the resize behavior of the SfTextArea.

    Declaration
    public Resize ResizeMode { get; set; }
    Property Value
    Type Description
    Resize

    One of the Resize enumeration. The default value is Both.

    Remarks
    • If the ResizeMode is None, the SfTextArea component should not be resizable ever.
    • If the ResizeMode is Horizontal, the SfTextArea component resizable horizontally always.
    • If the ResizeMode is Vertical, the SfTextArea component resizable vertically always.
    • If the ResizeMode is Both, the SfTextArea component resizable both vertically and horizontally always.
    Examples

    In the following code example, set the resize mode as Horizontal.

      <SfTextArea ResizeMode="Resize.Horizontal" Placeholder="Enter a value"></SfTextArea>

    RowCount

    Gets or sets the number of lines that are visible in the SfTextArea.

    Declaration
    public int RowCount { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer representing the number of lines. The default value is 2.

    Remarks

    The RowCount property specifies the visible height of the SfTextArea, measured in lines of text. This determines how many lines of text are visible without scrolling. A higher RowCount value increases the initial height of the SfTextArea.

    Examples
     
    <SfTextArea RowCount="4" Placeholder="Enter text"></SfTextArea> 

    ShowClearButton

    Gets or sets a value indicating whether the clear button is displayed in the SfTextArea.

    Declaration
    public bool ShowClearButton { get; set; }
    Property Value
    Type Description
    System.Boolean

    A boolean indicating whether the clear button is displayed. The default value is false.

    Remarks

    Set this property to true to show a clear button in the SfTextArea, allowing users to quickly remove all text content.

    Examples
     
    <SfTextArea ShowClearButton="true" Placeholder="Enter text" RowCount="4"></SfTextArea> 

    TabIndex

    Gets or sets the tab order of the SfTextArea component.

    Declaration
    public int TabIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer value representing the tab index of the SfTextArea component. The default value is 0.

    Remarks

    The TabIndex property determines the order in which the SfTextArea component receives focus when users navigate through the page using the Tab key. A higher TabIndex value means the element will be focused later in the tab sequence. Setting TabIndex to -1 removes the element from the tab sequence, making it non-focusable via keyboard navigation.

    Examples
      <SfTextArea TabIndex="1" Placeholder="Enter text"></SfTextArea>

    ValueChange

    Gets or sets the event callback that will be invoked when the content of SfTextArea has changed.

    Declaration
    public EventCallback<TextAreaValueChangeEventArgs> ValueChange { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<TextAreaValueChangeEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the value of the SfTextArea changes. The callback receives a TextAreaValueChangeEventArgs containing the changed value information.

    Remarks

    The ValueChange event is triggered when the user modifies the text content and the SfTextArea loses focus, or when the value is programmatically changed. This event provides the old and new values, allowing you to track changes and perform validation or other operations based on the modified content. Unlike the OnInput event, ValueChange is typically fired less frequently and is suitable for handling final value changes rather than real-time input tracking.

    Examples
    <SfTextArea Placeholder="Enter a value" ValueChange="@OnChange">
    </SfTextArea>
    @code{
        private void OnChange(TextAreaValueChangeEventArgs args)
        {
            var TextValue = args.Value;
        }
    }

    Width

    Gets or sets the width of the SfTextArea component.

    Declaration
    public string Width { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the width of the SfTextArea. The default value is null.

    Remarks

    Use this property to specify the width of the SfTextArea, supporting various units such as auto, cm, mm, in, px, pt, pc, %, em, ex, ch, rem, vw, vh, vmin, vmax. If the Width property is not set, the width of the SfTextArea is determined by the ColumnCount property. The ColumnCount property specifies the visible width of the SfTextArea, measured in average character widths, with a default value of 20.

    Examples
     
    <SfTextArea Width="300px" Placeholder="Enter text" RowCount="4"></SfTextArea> 

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    FocusAsync()

    Sets the focus to the SfTextArea component for interaction.

    Declaration
    public Task FocusAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous focus operation.

    Remarks

    This method asynchronously sets the focus to the SfTextArea component, enabling user interaction. When called, the textarea element will receive focus and become the active input field on the page. This is useful for programmatically directing user attention to the textarea or improving accessibility.

    Examples
    <SfTextArea @ref="textAreaRef" Placeholder="Enter your text here"></SfTextArea>
    
    @code {
        SfTextArea textAreaRef;
    
        private async Task SetFocusToTextArea()
        {
            await textAreaRef.FocusAsync();
        }
    }

    FocusOutAsync()

    Removes the focus from the SfTextArea component, if the component is in focus state.

    Declaration
    public Task FocusOutAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous focus removal operation.

    Remarks

    This method asynchronously removes the focus from the SfTextArea component if it currently has focus. When called, the textarea element will lose focus and will no longer be the active input field. This method is useful for programmatically controlling focus flow or implementing custom navigation patterns. If the component is not currently focused, this method will have no effect.

    Examples
    <SfTextArea @ref="textAreaRef" Placeholder="Enter your text here"></SfTextArea>
    
    @code {
        SfTextArea textAreaRef;
    
        private async Task RemoveFocusFromTextArea()
        {
            await textAreaRef.FocusOutAsync();
        }
    }

    GetPersistDataAsync()

    Gets the properties to be maintained in the persisted state.

    Declaration
    public Task<string> GetPersistDataAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task<System.String>

    A System.Threading.Tasks.Task<> of type System.String that represents the asynchronous operation. The result contains the persisted data as a JSON string, or null if no data is persisted.

    Remarks

    This method asynchronously retrieves the persisted state data for the SfTextArea component from the browser's local storage. The returned string contains the serialized properties that were previously saved using the component's persistence functionality. This method is typically used internally by the component to restore its state when the EnablePersistence property is enabled. The persisted data is stored using the component's ID as the key in the browser's local storage.

    Examples
    <SfTextArea @ref="textAreaRef" ID="myTextArea" EnablePersistence="true" Placeholder="Enter your text here"></SfTextArea>
    
    @code {
        SfTextArea textAreaRef;
    
        private async Task GetPersistedData()
        {
            string persistedData = await textAreaRef.GetPersistDataAsync();
            if (!string.IsNullOrEmpty(persistedData))
            {
                // Process the persisted data
                Console.WriteLine($"Persisted data: {persistedData}");
            }
        }
    }

    Implements

    System.IAsyncDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved