Textarea

A text field of several lines, growing with its text. In the look of the app's style.

FormsExperimental

Usage

import { Component, ViewEncapsulation } from '@angular/core';import { ScTextarea } from '@semantic-components/ui';
@Component({  selector: 'app-textarea-usage-demo',  imports: [ScTextarea],  template: `    <textarea      scTextarea      placeholder="Type your message here."      aria-label="Message"      class="max-w-sm"    ></textarea>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class TextareaUsageDemo {}

Anatomy

A directive on your textarea. In a field it is named, described and marked invalid by the field; a [formField] for Signal Forms.

import { ScTextarea } from '@semantic-components/ui';
<textarea scTextarea [formField]="…"></textarea>

Accessibility

  • Name it: a label (in a field, linked by itself) or aria-label.
  • In a field, its description and errors are read with it (aria-describedby); invalid once touched (aria-invalid).
  • It grows with its text (field-sizing: content), from its rows or min-height.

Examples

Field

Enter your message below.

import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldDescription,  ScLabel,  ScTextarea,} from '@semantic-components/ui';
/** In a field: named by its label, described by its description. */@Component({

Disabled

import { Component, ViewEncapsulation } from '@angular/core';import { ScField, ScLabel, ScTextarea } from '@semantic-components/ui';
/** disabled: dimmed, and nothing can be typed. */@Component({  selector: 'app-disabled-textarea-demo',  imports: [ScField, ScLabel, ScTextarea],  template: `    <div scField class="w-full max-w-sm">      <label scLabel>Message</label>

Invalid

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form, required } from '@angular/forms/signals';import {  ScField,  ScFieldErrors,  ScLabel,  ScTextarea,} from '@semantic-components/ui';
/** Invalid once touched (Signal Forms): marked, and its error read with it. */

With a send button

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton, ScTextarea } from '@semantic-components/ui';
/** A message and its send button. */@Component({  selector: 'app-button-textarea-demo',  imports: [ScButton, ScTextarea],  template: `    <div class="grid w-full max-w-sm gap-2">      <textarea

Form Example

Contact Us

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, email, form, required } from '@angular/forms/signals';import {  ScCard,  ScCardBody,  ScCardHeader,  ScCardTitle,  ScField,  ScInput,  ScLabel,

With Character Limit

Max 200 characters.

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form, maxLength } from '@angular/forms/signals';import {  ScField,  ScFieldDescription,  ScLabel,  ScTextarea,} from '@semantic-components/ui';
@Component({

Custom Rows

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScField, ScLabel, ScTextarea } from '@semantic-components/ui';
@Component({  selector: 'app-rows-textarea-demo',  imports: [FormField, ScField, ScLabel, ScTextarea],  template: `    <div class="grid w-full max-w-sm gap-4">      <div scField>

RTL

شاركنا أفكارك حول خدمتنا.

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldDescription,  ScLabel,  ScTextarea,} from '@semantic-components/ui';
/** In a right-to-left page: its text from the right. */

API reference

Each part takes class, merged over the style (cn: a later class wins).

PartSelectorDescription
ScTextareatextarea[scTextarea] A textarea in the style's look; in a field, its id, description and invalid state from the field; a [formField]; disabled.