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 Editors - Custom Text Editor Buttons
Text editors have built-in action buttons that allow users to open a drop-down menu, increase, decrease, or nullify the value, and perform other actions. To add custom action buttons for different scenarios, use the buttons[] array.
The USD/EUR rate is taken from www.wikipedia.org and is relevant on 14 April 2021
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, useMemo, useState } from 'react';
import { TextBox, Button as TextBoxButton, TextBoxTypes } from 'devextreme-react/text-box';
import { NumberBox, Button as NumberBoxButton, NumberBoxTypes } from 'devextreme-react/number-box';
import { DateBox, Button as DateBoxButton, DateBoxTypes } from 'devextreme-react/date-box';
import { ButtonTypes } from 'devextreme-react/button';
const millisecondsInDay = 24 * 60 * 60 * 1000;
const currencyLabel = { 'aria-label': 'Multi Currency' };
const dateBoxLabel = { 'aria-label': 'Date' };
const passwordLabel = { 'aria-label': 'Password' };
function App() {
const [passwordMode, setPasswordMode] = useState<TextBoxTypes.TextBoxType>('password');
const [currencyFormat, setCurrencyFormat] = useState('$ #.##');
const [currencyValue, setCurrencyValue] = useState(14500.55);
const [dateValue, setDateValue] = useState(new Date().getTime());
const passwordButton = useMemo<ButtonTypes.Properties>(
() => ({
icon: 'eyeopen',
stylingMode: 'text',
onClick: () => {
setPasswordMode((prevPasswordMode: string) =>
(prevPasswordMode === 'text' ? 'password' : 'text'));
},
}),
[setPasswordMode],
);
const currencyButton = useMemo<ButtonTypes.Properties>(
() => ({
text: '€',
stylingMode: 'text',
width: 32,
elementAttr: {
class: 'currency',
},
onClick: (e) => {
if (e.component.option('text') === '$') {
e.component.option('text', '€');
setCurrencyFormat('$ #.##');
setCurrencyValue((prevCurrencyValue: number) => prevCurrencyValue / 0.836);
} else {
e.component.option('text', '$');
setCurrencyFormat('€ #.##');
setCurrencyValue((prevCurrencyValue: number) => prevCurrencyValue * 0.836);
}
},
}),
[setCurrencyFormat, setCurrencyValue],
);
const todayButton = useMemo<ButtonTypes.Properties>(
() => ({
text: 'Today',
stylingMode: 'text',
onClick: () => {
setDateValue(new Date().getTime());
},
}),
[setDateValue],
);
const prevDateButton = useMemo<ButtonTypes.Properties>(
() => ({
icon: 'spinprev',
stylingMode: 'text',
onClick: () => {
setDateValue((prevDateValue: number) => prevDateValue - millisecondsInDay);
},
}),
[setDateValue],
);
const nextDateButton = useMemo<ButtonTypes.Properties>(
() => ({
icon: 'spinnext',
stylingMode: 'text',
onClick: () => {
setDateValue((prevDateValue: number) => prevDateValue + millisecondsInDay);
},
}),
[setDateValue],
);
const onDateChanged = useCallback(
(e: DateBoxTypes.ValueChangedEvent) => {
setDateValue(e.value);
},
[setDateValue],
);
const changeCurrency = useCallback(
(data: NumberBoxTypes.ValueChangedEvent) => {
setCurrencyValue(data.value);
},
[setCurrencyValue],
);
return (
<React.Fragment>
<div className="dx-fieldset">
<div className="dx-field">
<div className="dx-field-label">Password TextBox</div>
<div className="dx-field-value">
<TextBox
placeholder="password"
stylingMode="filled"
defaultValue="password"
inputAttr={passwordLabel}
mode={passwordMode}
>
<TextBoxButton
name="password"
location="after"
options={passwordButton}
/>
</TextBox>
</div>
</div>
<div className="dx-field">
<div className="dx-field-label">Multi-currency NumberBox</div>
<div className="dx-field-value">
<NumberBox
showClearButton={true}
showSpinButtons={true}
format={currencyFormat}
value={currencyValue}
inputAttr={currencyLabel}
onValueChanged={changeCurrency}
>
<NumberBoxButton
name="currency"
location="after"
options={currencyButton}
/>
<NumberBoxButton name="clear" />
<NumberBoxButton name="spins" />
</NumberBox>
</div>
</div>
<div className="dx-field">
<div className="dx-field-label">Advanced DateBox</div>
<div className="dx-field-value">
<DateBox
value={dateValue}
stylingMode="outlined"
inputAttr={dateBoxLabel}
onValueChanged={onDateChanged}
>
<DateBoxButton
name="today"
location="before"
options={todayButton}
/>
<DateBoxButton
name="prevDate"
location="before"
options={prevDateButton}
/>
<DateBoxButton
name="nextDate"
location="after"
options={nextDateButton}
/>
<DateBoxButton name="dropDown" />
</DateBox>
</div>
</div>
</div>
</React.Fragment>
);
}
export default App;
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
Each object in the buttons[] array should have the name field—the button's identifier. In addition, specify the button's location relative to the input text field and options of the Button component used as the action button.
The buttons[] array also accepts string values—the names of built-in buttons. Declare them in the order the buttons should have in the component. String and object declarations can be used in the same array.