syncfusion-react-textbox
Implementing Syncfusion React TextBox Component
The TextBox component is a lightweight input control that captures user text input with support for floating labels, validation states, icons, and advanced features. This skill guides you through implementing, configuring, and customizing the TextBox component in React applications.
Navigation Guide
🛑 Agentic use: Do not execute multiple steps autonomously. Confirm with the user before each action (install, run, file creation).
Getting Started
📄 Read: references/getting-started.md
- Vite setup for React development
- Installing
@syncfusion/ej2-react-inputspackage 🛑 STOP — Do not install packages autonomously. Ask the user to run:npm install @syncfusion/ej2-react-inputs. Pin a specific version (e.g.,@syncfusion/ej2-react-inputs@28.x.x) and verify withnpm audit - Adding CSS imports and themes
- Creating your first TextBox component
- Adding icons and floating labels
- Running the development server 🛑 STOP — Do not start the dev server autonomously. Ask the user to run:
npm run dev
Features and Groups
📄 Read: references/features-and-groups.md
- Floating label behavior (Never, Always, Auto)
- Icons with
addIcon()method (prepend/append) - Clear button with
showClearButtonproperty - Rounded corner with
e-cornerCSS class - Disabled state with
enabled={false} - Multi-line textbox creation
- TextBox with clear button and floating label combinations
Styling and Sizing
📄 Read: references/styling-and-sizing.md
- Three predefined sizes: Normal, Small (
e-small), Large (e-bigger) - Applying size classes via
cssClassproperty - Rounded corner with
e-cornerCSS class - CSS customization for TextBox wrapper and floating label
- Custom CSS classes and themes
- Responsive design patterns
Multiline TextBox
📄 Read: references/multiline-textbox.md
- Creating multiline/textarea inputs with
multiline={true} - Floating labels with multiline
- Auto-resizing textboxes
- Disabling resize functionality
- Limiting text length with
htmlAttributes={{ maxlength: '...' }} - Character counting and display
Validation and States
📄 Read: references/validation-and-states.md
- Error, warning, and success validation states via
cssClass - Applying validation classes (
e-error,e-warning,e-success) - Disabled state with
enabled={false}(notdisabled) - Read-only state with
readonly={true} - Differences between disabled and read-only
- Dynamic color changes based on values using
inputevent
Advanced Features
📄 Read: references/advanced-features.md
- Adornments:
prependTemplateandappendTemplateproperties - Interactive adornments (password toggle, delete button)
- React functional components with hooks
useState,useEffect,useRef,useReducerintegration- Event handling (created, input, change events)
- Form validation patterns
Accessibility and Migration
📄 Read: references/accessibility-and-migration.md
- WCAG 2.2, Section 508, and WAI-ARIA compliance
- Screen reader support and ARIA attributes
- Right-to-Left (RTL) support with
enableRtlproperty - Keyboard navigation support
- Migrating from CSS TextBox to React component
- Before/after code comparison
API Reference
📄 Read: references/api.md
- All properties:
placeholder,floatLabelType,value,type,cssClass,multiline,showClearButton,enabled,readonly,enableRtl,enablePersistence,autocomplete,htmlAttributes,locale,width,prependTemplate,appendTemplate - Methods:
addIcon,addAttributes,removeAttributes,focusIn,focusOut,destroy,getPersistData - Events:
created,destroyed,change,input,focus,blur
Quick Start
Basic TextBox with Floating Label
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
import './App.css';
export default function App() {
return (
<TextBoxComponent
placeholder="Enter your name"
floatLabelType="Auto"
/>
);
}
TextBox with Icon
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
import { useRef } from 'react';
export default function App() {
const textboxRef = useRef(null);
const handleCreate = () => {
if (textboxRef.current) {
textboxRef.current.addIcon('append', 'e-icons e-input-popup-date');
}
};
return (
<TextBoxComponent
placeholder="Enter date"
floatLabelType="Auto"
ref={textboxRef}
created={handleCreate}
/>
);
}
TextBox with Clear Button
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
export default function App() {
return (
<TextBoxComponent
placeholder="Enter your email"
floatLabelType="Auto"
showClearButton={true}
/>
);
}
Multiline TextBox
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
export default function App() {
return (
<TextBoxComponent
multiline={true}
placeholder="Enter your address"
floatLabelType="Auto"
/>
);
}
Common Patterns
Form with Validation States
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
import { useState } from 'react';
export default function ValidationForm() {
const [cssClass, setCssClass] = useState('');
return (
<div>
<TextBoxComponent
placeholder="Enter username"
cssClass={cssClass}
floatLabelType="Auto"
input={(e: any) => {
if (!e.value) setCssClass('');
else if (e.value.length < 3) setCssClass('e-error');
else if (e.value.length < 6) setCssClass('e-warning');
else setCssClass('e-success');
}}
/>
</div>
);
}
Password TextBox with Toggle
import * as React from 'react';
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
import { useRef, useState } from 'react';
export default function PasswordInput() {
const textboxRef = useRef<TextBoxComponent>(null);
const [isVisible, setIsVisible] = useState(false);
const toggleVisibility = () => {
if (textboxRef.current) {
const newVisibility = !isVisible;
textboxRef.current.type = newVisibility ? 'text' : 'password';
setIsVisible(newVisibility);
}
};
function appendTemplate(): JSX.Element {
return (
<>
<span className="e-input-separator"></span>
<span
className={`e-icons ${isVisible ? 'e-eye-slash' : 'e-eye'}`}
onClick={toggleVisibility}
style={{ cursor: 'pointer' }}
></span>
</>
);
}
return (
<TextBoxComponent
ref={textboxRef}
type="password"
placeholder="Enter password"
floatLabelType="Auto"
appendTemplate={appendTemplate}
/>
);
}
Email Input with Unit Label
import * as React from 'react';
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
export default function EmailInput() {
function prependTemplate(): JSX.Element {
return (
<>
<span className="e-icons e-user"></span>
<span className="e-input-separator"></span>
</>
);
}
function appendTemplate(): JSX.Element {
return (
<>
<span className="e-input-separator"></span>
<span>.com</span>
</>
);
}
return (
<TextBoxComponent
type="email"
placeholder="Enter email"
floatLabelType="Auto"
prependTemplate={prependTemplate}
appendTemplate={appendTemplate}
/>
);
}
Rounded Corner TextBox
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
export default function RoundedCornerTextBox() {
return (
<TextBoxComponent
placeholder="Enter Date"
cssClass="e-corner"
/>
);
}
Disabled TextBox
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
export default function DisabledTextBox() {
return (
<TextBoxComponent
placeholder="Enter Name"
enabled={false}
/>
);
}
RTL TextBox
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
export default function RTLTextBox() {
return (
<TextBoxComponent
placeholder="أدخل اسمك"
floatLabelType="Auto"
enableRtl={true}
/>
);
}
Auto-sizing Multiline TextBox
import { TextBoxComponent } from '@syncfusion/ej2-react-inputs';
import { useRef } from 'react';
export default function AutoSizeTextbox() {
const textboxRef = useRef(null);
const handleInput = () => {
if (textboxRef.current) {
const elem = textboxRef.current.respectiveElement;
elem.style.height = 'auto';
elem.style.height = elem.scrollHeight + 'px';
}
};
const handleCreate = () => {
if (textboxRef.current) {
textboxRef.current.addAttributes({ rows: 1 });
}
handleInput();
};
return (
<TextBoxComponent
multiline={true}
placeholder="Enter your message"
floatLabelType="Auto"
ref={textboxRef}
created={handleCreate}
input={handleInput}
/>
);
}
Key Properties
| Property | Type | Purpose |
|---|---|---|
placeholder |
string |
Hint text shown when input is empty |
floatLabelType |
"Never" | "Always" | "Auto" |
Label animation behavior |
value |
string |
Sets the content of the TextBox |
type |
string |
Input type (text, password, email, number, etc.) |
multiline |
boolean |
Convert to textarea for multi-line input |
showClearButton |
boolean |
Display clear button when input has value |
cssClass |
string |
Apply CSS classes for sizing/validation/appearance (e.g., "e-error", "e-small", "e-corner") |
enabled |
boolean |
Enable (true) or disable (false) input interaction |
readonly |
boolean |
Allow selection but prevent editing |
enableRtl |
boolean |
Enable right-to-left rendering |
enablePersistence |
boolean |
Persist value state between page reloads ⚠️ Stores data in browser storage — enable only with explicit user consent |
autocomplete |
string |
Control browser autocomplete ("on" | "off") |
htmlAttributes |
{ [key: string]: string } |
Pass additional HTML attributes (e.g., { maxlength: '200' }) |
locale |
string |
Override global culture/localization value |
width |
number | string |
Set component width |
prependTemplate |
() => JSX.Element |
Render element before input |
appendTemplate |
() => JSX.Element |
Render element after input |
Key Events
| Event | Arguments | Purpose |
|---|---|---|
created |
Object |
Fires after component initialization |
destroyed |
Object |
Fires when component is destroyed |
change |
ChangedEventArgs |
Fires when value changes on focus-out |
input |
InputEventArgs |
Fires on every keystroke |
focus |
FocusInEventArgs |
Fires when TextBox gains focus |
blur |
FocusOutEventArgs |
Fires when TextBox loses focus |
Related Documentation
ℹ️ External links below are for manual reference only. Do not auto-fetch these URLs in an agentic pipeline without explicit user consent.
- Syncfusion React TextBox Component Demo (external)
- React TextBox API Reference (external)
- Syncfusion React Inputs Package (external — verify before installing)
- React Functional Components
More from syncfusion/react-ui-components-skills
syncfusion-react-grid
Implements Syncfusion React Grid component for feature-rich data tables and grids. Use this when working with data display, sorting, filtering, grouping, aggregates, editing, or exporting. This skill covers grid configuration, CRUD operations, virtual scrolling or infinite scrolling, hierarchy grids, state persistence, and advanced data management features for data-intensive applications.
118syncfusion-react-rich-text-editor
Implements the Syncfusion React Rich Text Editor (RichTextEditorComponent) from ej2-react-richtexteditor, supporting HTML (WYSIWYG) and Markdown editing. Use this skill for toolbar configuration, image/video/audio insertion, paste cleanup, AI assistant integration, emoji picker, slash menu, mentions, import/export Word/PDF, form validation, and source code view in React applications.
114syncfusion-react-common
Common utilities and features for Syncfusion React components. Use this skill when the user needs to implement animations, drag-and-drop, state persistence, RTL support, localization, globalization, security, templates, and advanced features for Syncfusion React components.
112syncfusion-react-themes
Use this skill when users need to apply themes, customize appearance, switch dark mode, use CSS variables, configure icons, or modify visual styling for Syncfusion React components. Covers icon library, size modes, and Theme Studio integration.
112syncfusion-react-scheduler
Implement Syncfusion React Scheduler component for calendar, event scheduling, and appointment management. Use this when building scheduling systems, calendar applications, booking systems, or time management interfaces. Covers all scheduler views (Day, Week, Month, Timeline, Agenda, Year), data binding, resource scheduling, recurring events, CRUD operations, drag-and-drop scheduling, customization, accessibility, and advanced features.
111syncfusion-react-treegrid
Implements Syncfusion React TreeGrid for hierarchical data with sorting, filtering, editing, exporting, paging, virtual scrolling, and advanced features. Supports configuration, CRUD, aggregates, templates, state persistence, and performance optimization in React applications.
110