<Toolbar> component renders an action bar above the Gantt chart with buttons for adding, deleting, moving, indenting tasks, and (when enabled) undo/redo. It connects to the Gantt through the shared IApi instance.
Import
Basic usage
Pass theapi instance received from <Gantt init={setApi}> to wire the toolbar to the chart.
Props
The Gantt API instance. Obtain it from the
init callback or a ref on <Gantt>. When provided, the toolbar reads reactive state (selection, undo history, split-task mode) and dispatches actions back to the chart.Custom button definitions. When this array is non-empty it replaces the default button set entirely. When empty (the default), buttons are generated automatically from
getToolbarButtons() based on the current api state.Helper functions
getToolbarButtons(options?)
Returns the default toolbar button configuration array. Use this to obtain the full set of buttons and then add, remove, or modify individual entries before passing the result to the items prop.
| Option | Type | Description |
|---|---|---|
undo | boolean | Include undo and redo buttons. |
splitTasks | boolean | Include the split-task button. |
defaultToolbarButtons
The static default button array (without any reactive state applied). Useful as a reference for the available button IDs.
Default buttons
The default button set includes the following action IDs:| ID | Description |
|---|---|
add-task | Add a new task |
delete-task | Delete the selected task(s) |
indent-task | Indent (nest) the selected task |
unindent-task | Unindent the selected task |
move-task:up | Move the selected task up |
move-task:down | Move the selected task down |
split-task | Split the selected task (PRO) |
undo | Undo the last action (PRO) |
redo | Redo the last undone action (PRO) |
delete-task, indent-task, etc.) are automatically hidden when no tasks are selected.
Customizing buttons
Filtering default buttons
UsegetToolbarButtons() and filter or modify the result:
Replacing the toolbar entirely
For full control, build your own toolbar usingapi.exec() directly and skip the <Toolbar> component altogether: