How can I help you?
Getting Started with React TextArea component
10 Feb 20267 minutes to read
This section explains the steps required to create a simple React TextArea component and demonstrate its basic usage in a React environment.
Ready to streamline your Syncfusion® React development? Discover the full potential of Syncfusion® React components with Syncfusion® AI Coding Assistant. Effortlessly integrate, configure, and enhance your projects with intelligent, context-aware code suggestions, streamlined setups, and real-time insights—all seamlessly integrated into your preferred AI-powered IDEs like VS Code, Cursor, Syncfusion® CodeStudio and more. Explore Syncfusion® AI Coding Assistant.
To get started quickly with React TextArea, you can watch this video:
Setup for local development
Easily set up a React application using create-vite-app, which provides a faster development environment, smaller bundle sizes, and optimized builds compared to traditional tools like create-react-app. For detailed steps, refer to the Vite installation instructions. Vite sets up your environment using JavaScript and optimizes your application for production.
Note: To create a React application using
create-react-app, refer to this documentation for more details.
To create a new React application, run the following command.
npm create vite@latest my-appThis command will prompt you for a few settings for the new project, such as selecting a framework and a variant.

To set up a React application in TypeScript environment, run the following command.
npm create vite@latest my-app -- --template react-ts
cd my-app
npm run devTo set up a React application in JavaScript environment, run the following command.
npm create vite@latest my-app -- --template react
cd my-app
npm run devAdding Syncfusion® TextArea packages
All the available Essential® JS 2 packages are published in the npmjs.com public registry.
To install the TextArea component, use the following command
npm install @syncfusion/ej2-react-inputs --saveThe –save will instruct NPM to include the TextArea package inside of the dependencies section of the package.json.
Adding CSS reference
The following CSS files are available in the ../node_modules/@syncfusion package folder. Add these as references in src/App.css.
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-react-inputs/styles/tailwind3.css";To refer App.css in the application then import it in the src/App.tsx file.
Adding TextArea component
The React TextArea component can be added to the application by following these steps. To get started, add the TextArea component to the src/App.tsx file using the following code.
The following textarea code should be placed in the src/App.tsx file.
import { TextAreaComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import './App.css';
function App() {
return (
<TextAreaComponent id='default'></TextAreaComponent>
);
}
export default App;Run the application
Run the npm run dev command in the terminal to start the development server. This command compiles your code and serves the application locally, opening it in the browser.
npm run devThe output appears as follows.
// Import the TextArea.
import { TextAreaComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render TextArea.
function App() {
return (<div className='wrap'>
<TextAreaComponent id='default'></TextAreaComponent>
</div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('input-container'));// Import the TextArea.
import { TextAreaComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render TextArea.
function App() {
return (
<div className='wrap'>
<TextAreaComponent id='default'></TextAreaComponent>
</div>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('input-container'));Getting and setting values
To set the initial value of the TextArea component, use the value property. Here’s how you can achieve it:
import { TextAreaComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import './App.css';
function App() {
return (
<div className='wrap'>
<TextAreaComponent id='default' value='Comments'></TextAreaComponent>
</div>
);
}
export default App;- Alternatively, set the value of the TextArea using a state variable.
import { TextAreaComponent } from '@syncfusion/ej2-react-inputs';
import { useState } from 'react';
import * as React from 'react';
import './App.css';
function App() {
// Declare state variable textValue and a function setTextValue to update it.
const [textValue, setTextValue] = useState("comments");
return (
<div className='wrap'>
<TextAreaComponent id='default' value={textValue}></TextAreaComponent>
</div>
);
}
export default App;- Dynamically retrieve the value of the TextArea component using the state variable assigned to the
valueproperty.
import { TextAreaComponent } from '@syncfusion/ej2-react-inputs';
import { useState } from 'react';
import * as React from 'react';
import './App.css';
function App() {
const [textValue, setTextValue] = useState("comments");
function onButtonClick() {
// Get the value of the TextArea using state variable.
let value = textValue;
}
return (
<div className='wrap'>
<TextAreaComponent id='default' value={textValue}></TextAreaComponent>
<button id="valuebtn" onClick={onButtonClick.bind(this)}>Get Value</button>
</div>
);
}
export default App;- Retrieve the value of the TextArea by accessing it from the
changeevent arguments.
import { TextAreaComponent } from '@syncfusion/ej2-react-inputs';
import type { ChangedEventArgs } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import './App.css';
function App() {
// triggers when the content of TextArea has changed and gets focus-out.
function change(args: ChangedEventArgs) {
// Get the value of the TextArea from event arguments.
let value = args.value;
}
return (
<div className='wrap'>
<TextAreaComponent id='default' value='Comments' change={change}></TextAreaComponent>
</div>
);
}
export default App;Refer to the React TextArea feature tour page for its groundbreaking feature representations. You can also explore our React TextArea component example that shows how to render the TextArea in React.