onClick
Description
Fires when a control within the toolbar is clickedUsage
onClick?: (ev: {
item: {
id?: string | number;
comp?: string;
icon?: string;
css?: string;
text?: string;
menuText?: string;
key?: string;
spacer?: boolean;
collapsed?: boolean;
handler?: (item: item, value?: any) => void;
layout?: "column";
items?: item[];
[key: string]: any;
};
}) => void;
Parameters
The callback receives a single parameter ev
- an object with the following field:
item
- (required) the toolbar item that was clicked. For the full description of toolbar item properties, see items
Example
type OnClickResult = {
// clicked control item
item: {
id: string;
};
};
function handler(ev: OnClickResult): void {
const { item } = ev;
console.log("clicked control", item.id);
}
const items = [
{ id: "name", comp: "button" },
{ id: "email", comp: "button" },
];
function App() {
return <Toolbar items={items} onClick={handler} />;
}