View the source code for this component on GitHub: https://github.com/mcp-use/mcp-use/blob/main/libraries/typescript/packages/mcp-use/src/react/WidgetControls.tsx
WidgetControls
Wrapper component that adds control buttons for widget debugging and view controls (fullscreen and picture-in-picture). It combines a debug button and view controls under shared hover logic, so you can drop development and testing capabilities onto any widget by wrapping its content.children in a relatively positioned container and overlays a row of icon buttons. All buttons share the same hover logic and render together. The control row fades in on hover (opacity-100 / pointer-events-auto) and fades out otherwise (opacity-0 / pointer-events-none).
The component reads live widget data and actions from the useWidget() hook (props, output, metadata, state, theme, display mode, safe area, max height, locale, user agent, availability, and the callTool, sendFollowUpMessage, openExternal, requestDisplayMode, and setState actions). When rendered inside the inspector (detected when window.location.pathname includes /inspector/api/) all controls are hidden, because the inspector renders its own controls.
Props
SignatureThe widget content to wrap. Rendered inside the relatively positioned container, beneath the floating control row.Additional CSS classes applied to the wrapper container (which also carriesrelative h-fit).position"top-left" | "top-center" | "top-right" | "center-left" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right"default:"\"top-right\""Where the control buttons are placed within the wrapper. One of eight positions. Drives both the Tailwind position classes and the safe-area-aware inline offsets.When provided, hover detection is bound to this element viamouseenter/mouseleavelisteners instead of the wrapper. Use it to reveal the controls from a custom element. When set, the wrapper’s own hover handlers are skipped.Whether each button shows a hover tooltip with its label (for example “Fullscreen”, “Picture in Picture”, “Debug Info”). The tooltip position adapts to thepositionprop.Enables the debug button. Whentrue, a debug icon appears that toggles a full-screen overlay showing widget debug info and interactive action controls.Enables the view controls.trueshows both the picture-in-picture and fullscreen buttons,"pip"shows only the picture-in-picture button, and"fullscreen"shows only the fullscreen button. View control buttons are hidden while the widget is already infullscreenorpipdisplay mode.
debugger overlay
Whendebugger is true, the debug button toggles a fixed full-screen overlay (z-[10000]). The overlay closes on a backdrop click, on a click outside its content, and via an explicit close button, and it locks document.body scroll while open.
Debug Info table
ActionsCurrent widget props fromtoolInput.Tool output data (toolOutput).Response metadata (toolResponseMetadata).Persistent widget state (widgetState).Current theme, light or dark.Current display mode: inline, pip, or fullscreen.The user locale.The widget max height, displayed in pixels.Device capabilities, summarized as the device type.Safe area insets for mobile, shown asT B L Rvalues.Whether the widget API is available, shown as Yes or No.All available keys on thewindow.openaiobject, detected after mount.
Test calling another MCP tool. Takes a tool name and a JSON arguments string, then invokescallTool.Send a follow-up message to the conversation viasendFollowUpMessage.Open an external URL viaopenExternal.Request a display mode (Inline, PiP, or Fullscreen) viarequestDisplayMode.Update widget state viasetState(adds adebugTimestampto the current state).
viewControls buttons
WhenviewControls is enabled, the control row shows view-mode buttons. They are only visible while the widget is not already in fullscreen or pip display mode.
Buttons
Shown whenviewControlsistrueor"fullscreen". CallsrequestDisplayMode("fullscreen")to expand the widget to fullscreen.Shown whenviewControlsistrueor"pip". CallsrequestDisplayMode("pip")to show the widget in a floating window.
Basic Usage
Position Customization
Control buttons can be placed in any of the eight positions. The placement also reflows the hover tooltip and applies safe-area-aware offsets.Usage with McpUseProvider
WidgetControls is included automatically when you pass debugger or viewControls to McpUseProvider. This is the recommended approach since the provider also sets up the other providers a widget needs.
Related
- McpUseProvider: Unified provider that can include
WidgetControls. - useWidget: Hook for accessing widget data and actions, used internally by
WidgetControls.