-
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
React Toast - Stack
The DevExtreme Toast components can stack multiple notifications. Use the notify(message, stack) or notify(options, stack) method to display stacked messages.
These methods use a stack object that has the following structure: {position, direction}.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
import React, { useCallback, useState } from 'react';
import Button from 'devextreme-react/button';
import RadioGroup from 'devextreme-react/radio-group';
import SelectBox from 'devextreme-react/select-box';
import NumberBox from 'devextreme-react/number-box';
import Notify from 'devextreme/ui/notify';
import HideToasts from 'devextreme/ui/toast/hide_toasts';
import {
directions, positions, types, radioGroupItems, positionTopLabel, directionLabel,
positionBottomLabel, positionLeftLabel, positionRightLabel, positionLabel,
} from './data.ts';
type NotifyStack = (typeof Notify)['arguments'][1];
function App() {
const [id, setId] = useState(1);
const [isPredefined, setIsPredefined] = useState(true);
const [predefinedPosition, setPredefinedPosition] = useState('bottom center');
const [coordinatePosition, setCoordinatePosition] = useState({
top: undefined,
left: undefined,
bottom: undefined,
right: undefined,
});
const [direction, setDirection] = useState('up-push' as NotifyStack['direction']);
const topNumberBoxValueChanged = useCallback(
(top) => setCoordinatePosition({ ...coordinatePosition, top }),
[coordinatePosition, setCoordinatePosition],
);
const bottomNumberBoxValueChanged = useCallback(
(bottom) => setCoordinatePosition({ ...coordinatePosition, bottom }),
[coordinatePosition, setCoordinatePosition],
);
const leftNumberBoxValueChanged = useCallback(
(left) => setCoordinatePosition({ ...coordinatePosition, left }),
[coordinatePosition, setCoordinatePosition],
);
const rightNumberBoxValueChanged = useCallback(
(right) => setCoordinatePosition({ ...coordinatePosition, right }),
[coordinatePosition, setCoordinatePosition],
);
const show = useCallback(() => {
const position: NotifyStack['position'] = isPredefined ? predefinedPosition : coordinatePosition;
Notify({
message: `Toast ${id}`,
height: 45,
width: 150,
minWidth: 150,
type: types[Math.floor(Math.random() * 4)],
displayTime: 3500,
animation: {
show: {
type: 'fade', duration: 400, from: 0, to: 1,
},
hide: { type: 'fade', duration: 40, to: 0 },
},
}, {
position,
direction,
});
setId(id + 1);
}, [id, isPredefined, predefinedPosition, coordinatePosition, direction]);
return (
<React.Fragment>
<div className='options'>
<div>Position</div>
<RadioGroup
layout='horizontal'
defaultValue='predefined'
items={radioGroupItems}
onValueChange={(value) => setIsPredefined(value === 'predefined')} />
<SelectBox
items={positions}
value={predefinedPosition}
inputAttr={positionLabel}
onSelectionChanged={({ selectedItem }) => setPredefinedPosition(selectedItem)}
visible={isPredefined} />
<div className='section'>
<NumberBox
visible={!isPredefined}
placeholder='top'
defaultValue={null}
valueChangeEvent='keyup'
disabled={!!coordinatePosition.bottom}
inputAttr={positionTopLabel}
onValueChange={topNumberBoxValueChanged} />
<NumberBox
visible={!isPredefined}
placeholder='bottom'
defaultValue={null}
valueChangeEvent='keyup'
inputAttr={positionBottomLabel}
disabled={!!coordinatePosition.top}
onValueChange={bottomNumberBoxValueChanged} />
</div>
<div className='section'>
<NumberBox
visible={!isPredefined}
placeholder='left'
defaultValue={null}
valueChangeEvent='keyup'
inputAttr={positionLeftLabel}
disabled={!!coordinatePosition.right}
onValueChange={leftNumberBoxValueChanged} />
<NumberBox
visible={!isPredefined}
placeholder='right'
defaultValue={null}
valueChangeEvent='keyup'
inputAttr={positionRightLabel}
disabled={!!coordinatePosition.left}
onValueChange={rightNumberBoxValueChanged} />
</div>
<div>Direction</div>
<SelectBox
items={directions}
inputAttr={directionLabel}
value={direction}
onSelectionChanged={({ selectedItem }) => setDirection(selectedItem)} />
<div className='section'>
<Button text='Show' width='48%' onClick={show} />
<Button text='Hide all' width='48%' onClick={() => HideToasts()} />
</div>
</div>
</React.Fragment>
);
}
export default App;
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
Specify Position
You can set the position
field to a string (select 'predefined' in the radio group) or an object (select 'coordinates' in the radio group). Note that if you use coordinates for the position
field, you need to specify one vertical and one horizontal coordinate only. For example, if you specify 'top', the demo disables the 'bottom' field, and vice versa.
Specify Direction
The direction
field specifies two options: which way the notification stack grows and whether new notifications appear at the end or at the beginning of the line. For this reason, the field's pull-down menu choices show pairs of values such as 'up-push' and 'up-stack'.
-
'up-push'
New toasts push the previous toasts upwards. -
'up-stack'
Toasts stack on top of each other.
Hide Toasts
To hide all toast messages, use the hideToasts method.