WidgetControls
TheWidgetControls component adds control buttons for widget debugging and view controls (fullscreen/pip). It combines debug button and view controls with shared hover logic, making it easy to add development and testing capabilities to your widgets.
Import
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | required | The widget content to wrap |
debugger | boolean | false | Enable debug button to display widget debug information |
viewControls | boolean | "pip" | "fullscreen" | false | Enable view controls. true = both pip and fullscreen, "pip" = only pip, "fullscreen" = only fullscreen |
position | "top-left" | "top-center" | "top-right" | "center-left" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right" | "top-right" | Position of the control buttons |
attachTo | HTMLElement | null | undefined | Element to attach controls to (for custom positioning) |
showLabels | boolean | true | Show labels on control buttons |
className | string | "" | Additional CSS classes |
Basic Usage
Debug Button
The debug button opens an overlay showing:- Props: Current widget props from
toolInput - Output: Tool output data (
toolOutput) - Metadata: Response metadata (
toolResponseMetadata) - State: Persistent widget state (
widgetState) - Theme: Current theme (light/dark)
- Display Mode: Current display mode (inline/pip/fullscreen)
- Safe Area: Safe area insets for mobile
- User Agent: Device capabilities
- Locale: User locale
- window.openai Keys: All available keys on the
window.openaiobject
- Call Tool: Test calling other MCP tools
- Send Follow-up Message: Send messages to ChatGPT conversation
- Open External: Test opening external URLs
- Set State: Update widget state
View Controls
View controls allow users to change the widget’s display mode:- Fullscreen Button: Expands widget to fullscreen mode
- Picture-in-Picture Button: Shows widget in a floating window
Position Customization
Control buttons can be positioned in 8 different locations:Hover Behavior
All control buttons share the same hover logic:- Hidden by default: Controls are invisible (
opacity-0) until hovered - Show on hover: Controls become visible (
opacity-100) when hovering over the widget - Smooth transition: 200ms transition for smooth appearance/disappearance
Dev Mode Detection
When running in the inspector’s dev widget proxy (/inspector/api/dev-widget/), the controls are automatically hidden since the inspector provides its own debugging interface. This prevents duplicate controls.
Usage with McpUseProvider
WidgetControls is automatically included when using McpUseProvider with the debugger or viewControls props:
Standalone Usage
You can also useWidgetControls standalone if you’re managing other providers yourself:
Related Components
McpUseProvider- Unified provider that includes WidgetControlsuseWidget- Hook for accessing widget data and actions