Quick Access Toolbar in React Image Editor
03 Sep 20265 minutes to read
The quick access toolbars in the React Image Editor facilitate interactions with annotations such as Rectangle, Ellipse, Line, Arrow, and Path. The toolbar is only displayed when an annotation is selected, ensuring a focused and contextual user experience.
The showQuickAccessToolbar property controls the visibility of the quick access toolbar (default: true). You can enable or disable this toolbar, add or remove items, and create a personalized set of tools.
Add a custom toolbar item
The quick access toolbar that appears when inserting annotations is customizable using the quickAccessToolbarOpen event. This event is triggered when the quick access toolbar is opened, allowing you to modify its contents.
Use the event handler’s args.toolbarItems to add or remove items. Modify items based on args.shape (for example, ‘Rectangle’ or ‘Line’), or set args.cancel = true to cancel opening when appropriate.
QuickAccessToolbarEventArgs properties:
-
cancel: Specifies whether to cancel the quick access toolbar opening action. -
shape: The type of shape to be selected such as Rectangle, Text, Line, Ellipse, Arrow, Path, Image, or Freehand draw. -
toolbarItems: The collection of toolbar items to be rendered in the quick access toolbar.
Example: add a custom quick access toolbar item.
import { ImageEditorComponent } from '@syncfusion/ej2-react-image-editor';
import { Browser } from '@syncfusion/ej2-base';
import * as React from 'react';
import * as ReactDOM from "react-dom";
export default class App extends React.Component {
imgObj;
imageEditorCreated() {
if (Browser.isDevice) {
this.imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/flower.jpeg');
}
else {
this.imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/bridge.jpeg');
}
}
quickAccessToolbarOpen(args) {
args.toolbarItems = ['Clone'];
}
render() {
return (<div className='e-img-editor-sample'>
<ImageEditorComponent ref={(img) => { this.imgObj = img; }} height="350px" created={this.imageEditorCreated.bind(this)} quickAccessToolbarOpen={this.quickAccessToolbarOpen.bind(this)}></ImageEditorComponent>
</div>);
}
}
ReactDOM.render(<App />, document.getElementById('image-editor'));import { ImageEditorComponent } from '@syncfusion/ej2-react-image-editor';
import { Browser } from '@syncfusion/ej2-base';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
let imgObj: ImageEditorComponent;
function imageEditorCreated(): void {
if (Browser.isDevice) {
imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/flower.jpeg');
} else {
imgObj.open('https://ej2.syncfusion.com/react/documentation/image-editor/images/bridge.jpeg');
}
}
function quickAccessToolbarOpen(args: any): void {
args.toolbarItems = ['Clone'];
}
return (
<div className='e-img-editor-sample'>
<ImageEditorComponent ref={(img) => { imgObj = img }} created={imageEditorCreated} quickAccessToolbarOpen={quickAccessToolbarOpen} ></ImageEditorComponent>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('image-editor'));<!DOCTYPE html>
<html lang="en">
<head>
<title>Syncfusion React Image Editor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for React Components" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css"rel="stylesheet">
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='image-editor'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>