Articles in this section

How to customize the TextArea row fields in Blazor DataForm component?

This article provides a guide on how to customize the height of TextArea in Blazor Data Form by setting the rows attribute.

Adjusting TextArea Rows in DataForm

To customize the number of rows in a TextArea field within DataForm, you can use a template feature tailored for the specific field. In this template, the TextBox component is used with the Multiline property set to true. Then, the HtmlAttributes property is used to specify the number of rows for the TextArea. In the example provided below, the rows attribute is set to 5, indicating that the TextArea field will display five rows.

Here is an example code snippet that demonstrates how to implement this in DataForm:

<SfDataForm ID="MyForm"
            Width="100%"
            Model="@EventRegistrationModel">
    <FormValidator>
        <DataAnnotationsValidator></DataAnnotationsValidator>
    </FormValidator>
    <FormItems>
        <FormItem Field="@nameof(EventRegistration.Name)" Placeholder="e.g. Andrew Fuller"></FormItem>
        <FormItem Field="@nameof(EventRegistration.Email)" Placeholder="e.g. [email protected]"></FormItem>
        <FormItem Field="@nameof(EventRegistration.TextAreaField)">
            <Template>
                <SfTextBox Multiline=true @bind-Value="EventRegistrationModel.TextAreaField" HtmlAttributes="@(new Dictionary<string,object>() { { "rows", 5 } })"></SfTextBox>
            </Template>
        </FormItem>
    </FormItems>
</SfDataForm>

Sample

Explore a live sample here: Blazor DataForm TextArea Sample

Documentation

For more detailed information on how to use templates in Blazor DataForm, please refer to the official documentation:

Conclusion

We hope you enjoyed learning about how to customize the TextArea row height in the Blazor DataForm component.

You can refer to our Blazor DataForm feature tour page to learn about its other groundbreaking features, documentation, and how to quickly get started with configuration specifications.

For current customers, our Blazor components are available on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to evaluate our Blazor DataForm and other Blazor components.

If you have any questions or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied