Remove a tool from the toolbar
Remove the text tool from the toolbar and keyboard shortcuts with a tools override.
import { TLUiOverrides, Tldraw } from 'tldraw'
import 'tldraw/tldraw.css'
// [1]
const overrides: TLUiOverrides = {
tools(_editor, tools) {
delete tools.text
return tools
},
}
export default function RemoveToolExample() {
return (
<div className="tldraw__editor">
<Tldraw overrides={overrides} />
</div>
)
}
/*
[1]
The `tools` override receives the map of UI tool items and returns the map the
UI should use. Deleting an entry removes the tool from the toolbar, its
keyboard shortcut, and the keyboard shortcuts dialog. The tool itself is still
registered with the editor, so `editor.setCurrentTool('text')` still works.
Define the overrides object outside the component (or memoize it) so the UI
doesn't rebuild on every render.
*/
The tools override in TLUiOverrides receives the map of UI tool items and returns the one the UI should use. Deleting an entry removes that tool from the toolbar, its keyboard shortcut, and the keyboard shortcuts dialog. The tool is still registered with the editor, so it can be activated programmatically with editor.setCurrentTool. Here we remove the text tool; try pressing T and note that nothing happens.
Is this page helpful?
Prev
Add a tool to the toolbarNext
Change default colors