Pull down to refresh...
Release to refresh...
Refreshing...
-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
- Overview
-
Action Sheet
-
Button
- Floating Action Button
- Drop Down Button
-
Context Menu
-
List
-
Lookup
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
Related Demos:
Your search did not match any results.
Loading...
React Select Box - Overview
The SelectBox component allows users to select an item from a drop-down list.
DevExtreme Accessibility Compliance
DevExtreme component libraries meet a variety of WCAG and Section 508 compliance standards. To assess this demo’s accessibility level, click the Run AXE® Validation button to launch the AXE® web accessibility evaluation tool.
All trademarks or registered trademarks are property of their respective owners. AXE® Terms of Use
The overall accessibility level of your application depends on the SelectBox features used.
To give you the ability to edit code on the fly, the demo uses SystemJS. For this reason, launching the demo takes some time. We strongly recommend that you do not use this approach in real projects.
Was this demo helpful?
Feel free to share demo-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Backend API
x
import React, { useCallback, useState } from 'react';
import SelectBox, { SelectBoxTypes } from 'devextreme-react/select-box';
import ArrayStore from 'devextreme/data/array_store';
import notify from 'devextreme/ui/notify';
import service from './data.ts';
import Field from './Field.tsx';
import Item from './Item.tsx';
const simpleProductLabel = { 'aria-label': 'Simple Product' };
const productIDLabel = { 'aria-label': 'Product ID' };
const productWithPlaceholderLabel = { 'aria-label': 'Product With Placeholder' };
const productLabel = { 'aria-label': 'Product' };
const readOnlyProductLabel = { 'aria-label': 'ReadOnly Product' };
const templatedProductLabel = { 'aria-label': 'Templated Product' };
const disabledProductLabel = { 'aria-label': 'Disabled Product' };
const products = service.getProducts();
const simpleProducts = service.getSimpleProducts();
const data = new ArrayStore({
data: products,
key: 'ID',
});
function App() {
const [value, setValue] = useState(service.getSimpleProducts()[0]);
const onValueChanged = useCallback((e: SelectBoxTypes.ValueChangedEvent) => {
setValue(e.value);
notify(`The value is changed to: "${e.value}"`);
}, []);
return (
<div>
<div className="dx-fieldset">
<div className="dx-field">
<div className="dx-field-label">Default mode</div>
<div className="dx-field-value">
<SelectBox
items={simpleProducts}
inputAttr={simpleProductLabel}
/>
</div>
</div>
<div className="dx-field">
<div className="dx-field-label">With a custom placeholder</div>
<div className="dx-field-value">
<SelectBox
items={simpleProducts}
placeholder="Choose Product"
inputAttr={productWithPlaceholderLabel}
showClearButton={true}
/>
</div>
</div>
<div className="dx-field">
<div className="dx-field-label">Read only</div>
<div className="dx-field-value">
<SelectBox
items={simpleProducts}
defaultValue={simpleProducts[0]}
inputAttr={readOnlyProductLabel}
readOnly={true}
/>
</div>
</div>
<div className="dx-field">
<div className="dx-field-label">Disabled</div>
<div className="dx-field-value">
<SelectBox
items={simpleProducts}
inputAttr={disabledProductLabel}
defaultValue={simpleProducts[0]}
disabled={true}
/>
</div>
</div>
<div className="dx-field">
<div className="dx-field-label">Data source usage</div>
<div className="dx-field-value">
<SelectBox
dataSource={data}
displayExpr="Name"
inputAttr={productIDLabel}
valueExpr="ID"
defaultValue={products[0].ID}
/>
</div>
</div>
<div className="dx-field">
<div className="dx-field-label">Custom templates</div>
<div className="dx-field-value">
<SelectBox
id="custom-templates"
dataSource={products}
displayExpr="Name"
inputAttr={templatedProductLabel}
valueExpr="ID"
defaultValue={products[3].ID}
fieldRender={Field}
itemRender={Item}
/>
</div>
</div>
</div>
<div className="dx-fieldset">
<div className="dx-fieldset-header">Event Handling</div>
<div className="dx-field">
<div className="dx-field-label">Product</div>
<div className="dx-field-value">
<SelectBox
items={simpleProducts}
value={value}
inputAttr={productLabel}
onValueChanged={onValueChanged}
/>
</div>
</div>
<div className="current-value">
Selected product is <span>{value}</span>
</div>
</div>
</div>
);
}
export default App;
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
This demo illustrates the following SelectBox properties:
- items
Specifies an array of items displayed in the SelectBox. - placeholder
Specifies the text that is displayed when no items are selected. - readOnly
Prevents users from changing the editor's value via the UI. - disabled
Specifies whether the SelectBox responds to user interaction. - dataSource
Binds the SelectBox to data. Unlike the items property, dataSource accepts the DataSource object that allows users to sort, filter, group, and shape data. - fieldTemplate and itemTemplate
Allow you to customize the text field and drop-down list items. - onValueChanged event handler
Use this function to perform an action when a user chooses a new value. In this demo, this function is used to display the selected value.
To get started with the DevExtreme SelectBox component, refer to the following tutorial for step-by-step instructions: Getting Started with SelectBox.