DevExtreme React - Relocate an Item

Toolbar items are aligned to the left (right if rtlEnabled is true) and preserve the order they have in the items array. Use the location option to override the order.

This option accepts the "before", "center", and "after" values that specify a toolbar item's location relative to that of other items. In the code below, it is used to order items as follows: alignLeft, alignRight, color, background, undo, and redo. Note that alignLeft and alignRight assume the default value, "before".

  • import React from 'react';
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { HtmlEditor, Toolbar, Item } from 'devextreme-react/html-editor';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <HtmlEditor>
  • <Toolbar>
  • <Item
  • formatName="undo"
  • location="after"
  • />
  • <Item
  • formatName="redo"
  • location="after"
  • />
  • <Item formatName="alignLeft"/>
  • <Item formatName="alignRight"/>
  • <Item
  • formatName="color"
  • location="center"
  • />
  • <Item
  • formatName="background"
  • location="center"
  • />
  • </Toolbar>
  • </HtmlEditor>
  • );
  • }
  • }
  •  
  • export default App;

If the toolbar cannot fit all the items, some of them are collected in the overflow menu. Use the locateInMenu option to change this behavior:

  • import React from 'react';
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { HtmlEditor, Toolbar, Item } from 'devextreme-react/html-editor';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <HtmlEditor>
  • <Toolbar>
  • <Item
  • formatName="undo"
  • locateInMenu="always"
  • />
  • <Item
  • formatName="color"
  • locateInMenu="never"
  • />
  • </Toolbar>
  • </HtmlEditor>
  • );
  • }
  • }
  •  
  • export default App;