Forms
Text area
Multi-line text that grows one line at a time.
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
| Property | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Désactive le champ. |
error | string | — | 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. |
hint | string | — | Texte d'aide, lu par les lecteurs d'écran. |
label (obligatoire) | string | — | Libellé affiché au-dessus du champ. |
maxRows | number | 8 | Nombre de lignes au-delà duquel le champ défile au lieu de grandir. |
name | string | — | Nom envoyé avec le formulaire. |
placeholder | string | — | Texte indicatif affiché quand le champ est vide. |
required | boolean | false | Rend la saisie obligatoire. |
rows | number | 1 | Nombre de lignes au départ. |
value | string | '' | Texte saisi. |
Events
| React | event.detail | Description |
|---|---|---|
onCrInput | string | Émis à chaque frappe ; detail : le texte. |
Slots
| Slot | Description |
|---|---|
slot="end" | Contenu placé en bas à droite du champ (bouton d'envoi…). |
CSS parts
To style it from outside: cr-textarea::part(name) { … }
| Part | Description |
|---|---|
control | La zone de texte. |
label | Le libellé. |