Loading...
Loading...
Guide for implementing Syncfusion React ListBox component. Use this when working with list selection components, build dropdown-like lists with custom templates, enable multi-selection, implement drag-and-drop functionality, add filtering/searching to lists, create accessibility-compliant list boxes, or need to handle list item templates and styling. Perfect for selection menus, item pickers, dual-list transfers, and filterable item lists.
npx skill4agent add syncfusion/react-ui-components-skills syncfusion-react-list-boxSelectionSettingsModelToolbarSettingsModelFieldSettingsModelSourceDestinationModelimport { ListBoxComponent } from '@syncfusion/ej2-react-dropdowns';
import './App.css';
function App() {
const data = [
{ text: 'JavaScript', id: '1' },
{ text: 'TypeScript', id: '2' },
{ text: 'React', id: '3' },
{ text: 'Vue', id: '4' },
{ text: 'Angular', id: '5' }
];
const handleChange = (e) => {
console.log('Selected:', e.value);
};
return (
<ListBoxComponent
dataSource={data}
fields={{ text: 'text', value: 'id' }}
selectionSettings={{ mode: 'Single' }}
change={handleChange}
/>
);
}
export default App;<ListBoxComponent
dataSource={data}
selectionSettings={{ mode: 'Multiple' }}
/>Requires injectingservice.CheckBoxSelection
import { ListBoxComponent, SelectionSettingsModel, Inject, CheckBoxSelection } from '@syncfusion/ej2-react-dropdowns';
const selectionSettings: SelectionSettingsModel = { showCheckbox: true };
<ListBoxComponent dataSource={data} selectionSettings={selectionSettings}>
<Inject services={[CheckBoxSelection]} />
</ListBoxComponent><ListBoxComponent
dataSource={data}
allowFiltering={true}
filterBarPlaceholder="Search items"
/>const itemTemplate = (props) => {
return (
<div>
<span className="icon">{props.icon}</span>
<span>{props.text}</span>
</div>
);
}
<ListBoxComponent
dataSource={data}
itemTemplate={itemTemplate}
/><ListBoxComponent
dataSource={groupedData}
fields={{ text: 'text', groupBy: 'category' }}
/>| Prop | Purpose | Example |
|---|---|---|
| Array of items to display | |
| Maps data properties to display | |
| Defines selection mode and checkbox display. For | |
| Enables filter search box | |
| Enables item drag-drop | |
| Custom template for items | Function returning JSX |
| Enables/disables the component | |