Infragistics
Close
Angular React Web Components Blazor Blazor
Open Source

Blazor Text Area Overview

The Ignite UI for Blazor Text Area represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizable amount of free-form text, for example a comment on a review or feedback form.

Blazor Text Area Example

Dependencies

Register the Ignite UI for Blazor services:

// in Program.cs file

builder.Services.AddIgniteUIBlazor();

Registering IgbTextareaModule, the Text Area’s client resource module, is optional: the component loads its resources when it first renders. Listing it in builder.Services.AddIgniteUIBlazor(typeof(IgbTextareaModule)) can be used to preload resources or to support elements created only on the client (see Component Modules).

You will also need to link an additional CSS file to apply the styling to the IgbTextarea component. The following needs to be placed in the app’s host page (wwwroot/index.html in a standalone Blazor WebAssembly or Blazor Hybrid app, Pages/_Host.cshtml in a Blazor Server app, Components/App.razor in a Blazor Web App):

<link href="_content/IgniteUI.Blazor/themes/light/bootstrap.css" rel="stylesheet" />

After we import the IgbTextarea component we are ready to start using it, so let’s add our first Text Area.

<IgbTextarea Rows="5" Label="Tell us your story:">It was a dark and stormy night...</IgbTextarea>

Prefix, Suffix & Helper Text

With prefix and suffix slots we can add different content before and after the main content of the Text Area. The helper-text slot provides a hint placed below the Text Area. When slotting content, we recommend using a <span> element for simple text, symbols, or emojis, and an <igc-icon> component for icons. In the following sample, we will create a new Text Area field with an icon prefix and helper text as a hint:

<IgbTextarea Label="Your feedback">
    <IgbIcon IconName="feedback" Collection="material" slot="prefix"></IgbIcon>
    <span slot="helper-text">Give us a short description of what you liked/disliked</span>
</IgbTextarea>

Text Area Resizing

There are three different resize options of the IgbTextarea. When set to none, the text area does not resize and uses a scroll bar to show overflow text. When set to vertical (the default option), the text area lets the user resize it vertically. When set to auto, the text area shows all the user input at once. Overflow text wraps onto a new line and expands the text area automatically.

Form Integration

The sample below shows how a IgbTextarea could be integrated into a form.

Styling

The IgbTextarea component exposes CSS parts for almost all of its inner elements. The following table lists all of the exposed CSS parts:

Name Description
container The main wrapper that holds all main input elements.
input The native input element.
label The native label element.
prefix The prefix wrapper.
suffix The suffix wrapper.
helper-text The helper text wrapper.
igc-textarea::part(input) {
  background-color: var(--ig-info-100);
  border-color: var(--ig-primary-400);
}

igc-textarea::part(label) {
  color: var(--ig-gray-800);
}

igc-textarea::part(prefix),
igc-textarea::part(suffix) {
  color: var(--ig-primary-500-contrast);
  border-color: var(--ig-primary-500);
  background-color: var(--ig-primary-500);
}

API References

Additional Resources