Skip to content

TextareaAutosize

The TextareaAutosize component automatically adjusts its height to fit the content.

To use the TextareaAutosize component, import it from your components and pass the necessary props.

A simple TextareaAutosize with basic usage.

import React from 'react';
import { TextareaAutosize } from '@firecms/ui';
export default function TextareaAutosizeBasicDemo() {
return (
<TextareaAutosize
placeholder="Type your text here..."
/>
);
}

An example of a controlled TextareaAutosize component.

import React, { useState } from "react";
import { TextareaAutosize } from "@firecms/ui";
export default function TextareaAutosizeControlledDemo() {
const [value, setValue] = useState("Controlled textarea");
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
setValue(event.target.value);
};
return (
<TextareaAutosize
value={value}
onChange={handleChange}
placeholder="Type your text here..."
/>
);
}

Demonstrating how to set the minimum and maximum number of rows.

import React from "react";
import { TextareaAutosize } from "@firecms/ui";
export default function TextareaAutosizeRowsDemo() {
return (
<TextareaAutosize
placeholder="Type your text here..."
minRows={3}
maxRows={6}
/>
);
}