Skip to Content
Cristal

Forms

Text area

Multi-line text that grows one line at a time.

<cr-textarea>CrTextarea

Example

The field starts at rows lines (1 by default) and grows one line at a time, with a slight bounce, up to maxRows (8 by default); beyond that, it scrolls. The end slot places a button at the bottom right, for example to send.

↑
import { CrButton, CrTextarea } from '@cristal-ui/react';

export default function TextareaBasic() {
  return (
    <CrTextarea label="Note" name="note" placeholder="Write a note…" maxRows={6} style={{ width: '100%', maxWidth: 420 }}>
      <CrButton slot="end" size="xs" aria-label="Send note">
        ↑
      </CrButton>
    </CrTextarea>
  );
}

Keyboard

Enter inserts a new line; Ctrl + Enter (Cmd + Enter on Mac) submits the form.

error-animation animates the error when it appears and on every rejected submit (zigzag, badge, echo…): see Animated error.

API

Properties

PropertyTypeDefaultDescription
disabledbooleanfalseDésactive le champ.
errorstring—Message d'erreur ; remplace le message automatique.
errorAnimation"drop" | "echo" | "jitter" | "none" | "pop" | "wobble" | "zigzag"'none'Animation de l'erreur quand elle apparaît et à chaque envoi refusé : none (par défaut), zigzag, pop, drop, echo, jitter ou wobble.
hintstring—Texte d'aide, lu par les lecteurs d'écran.
label (obligatoire)string—Libellé affiché au-dessus du champ.
maxRowsnumber8Nombre de lignes au-delà duquel le champ défile au lieu de grandir.
namestring—Nom envoyé avec le formulaire.
placeholderstring—Texte indicatif affiché quand le champ est vide.
requiredbooleanfalseRend la saisie obligatoire.
rowsnumber1Nombre de lignes au départ.
valuestring''Texte saisi.

Events

Reactevent.detailDescription
onCrInputstringÉmis à chaque frappe ; detail : le texte.

Slots

SlotDescription
slot="end"Contenu placé en bas à droite du champ (bouton d'envoi…).

CSS parts

To style it from outside: cr-textarea::part(name) { … }

PartDescription
controlLa zone de texte.
labelLe libellé.

On this page