@mocanvas/editor · function

useIsToolSelected

declare function useIsToolSelected(tool: TLUiToolItem | undefined): boolean

Whether a tool item is the active one, tracked reactively.

Takes the item rather than its id, and accepts undefined, so a toolbar button can call it before it has decided whether to render at all — a hook cannot be called conditionally.

An item carrying meta.geo drives the shared geo tool, so being active means *both* that geo is the current tool and that it is set to that item's kind; otherwise the item's id is compared to the current tool id.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.