Files
copilotkit__copilotkit/docs/snippets/shared/guides/default-tool-rendering.mdx
Tyler Slaton 1ca902c568 docs: add default tool rendering guide (#2717)
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2025-11-13 14:03:40 -05:00

36 lines
1.0 KiB
Plaintext

`useDefaultTool` provides a catch-all renderer for **any tool** that doesn't have a specific `useRenderToolCall` defined. This is useful for:
- Displaying all tool calls during development
- Rendering MCP (Model Context Protocol) tools
- Providing a generic fallback UI for unexpected tools
```tsx title="app/page.tsx"
import { useDefaultTool } from "@copilotkit/react-core"; // [!code highlight]
// ...
const YourMainContent = () => {
// ...
// [!code highlight:15]
useDefaultTool({
render: ({ name, args, status, result }) => {
return (
<div style={{ color: "black" }}>
<span>
{status === "complete" ? "✓" : "⏳"}
{name}
</span>
{status === "complete" && result && (
<pre>{JSON.stringify(result, null, 2)}</pre>
)}
</div>
);
},
});
// ...
}
```
<Callout type="info">
Unlike `useRenderToolCall`, which targets a specific tool by name, `useDefaultTool` catches **all** tools that don't have a dedicated renderer.
</Callout>