You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ec998a0
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/tools/show-widget.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,12 @@ read_when:
15
15
16
16
When the agent calls `show_widget`, OpenClaw core wraps `widget_code` in a minimal HTML document, stores it as a Canvas document, and returns a preview handle. The Control UI renders that handle as a sandboxed iframe directly under the tool call, while native apps use an isolated web view. Both restore the widget after history reload.
17
17
18
-
For browser embedding, the wrapper document injects three small host bridges around the widget code:
18
+
For browser embedding, the wrapper document injects four small host bridges around the widget code:
19
19
20
20
- A size reporter posts the rendered content height to the embedding chat, which clamps it and fits the iframe (160 to 1200 pixels).
21
21
- A prompt bridge defines a global `sendPrompt(text)` function that widget scripts can call to submit a follow-up message into the chat. The bridge creates a private message channel and offers one endpoint to the chat before any widget code runs; the chat adopts only that first offer. See [Interactive widgets](#interactive-widgets).
22
22
- A theme bridge listens for the Control UI's current design tokens and applies them as CSS variables, on load and again on every theme change.
23
+
- A snapshot bridge renders the current widget document as a PNG when the embedding chat requests an export.
23
24
24
25
Everything else stays inside the frame: the document runs in an opaque origin with a strict Content Security Policy, so widget scripts cannot reach the Control UI, the Gateway, or the network.
25
26
@@ -70,6 +71,8 @@ Author widgets with three rules:
70
71
2. Keep the page background transparent so the widget belongs to its host surface.
71
72
3. Reserve `--accent-fill` for at most one primary action.
72
73
74
+
**Export:** In web chat, open the widget card menu to copy the rendered widget to the clipboard or download it as a PNG. Older widget documents without the snapshot bridge fall back to an HTML file download.
75
+
73
76
## Use the tool
74
77
75
78
Both implementations use the same required fields:
0 commit comments