openclaw - 💡(How to fix) Fix Feature request: Add width parameter to [embed] directive [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70221Fetched 2026-04-23 07:27:36
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
closed ×1reopened ×1

Fix Action

Fix / Workaround

Current workaround

  • Browser CSS injection (Stylus/Violent Monkey) targeting .chat-tool-card__preview-frame or .chat-tool-card__preview-panel
  • Opening Canvas Host URL directly in a separate browser tab
  • Patching node_modules CSS

Code Example

function renderPreviewFrame(params: {
  title: string;
  src?: string;
  height?: number;
  sandbox?: string;
}) {
  return html\`
    <iframe
      class="chat-tool-card__preview-frame"
      title=${params.title}
      sandbox=${params.sandbox ?? ""}
      src=${params.src ?? nothing}
      style=${params.height ? \`height:${params.height}px\` : ""}
    ></iframe>
  `;
}

---

style=${params.height ? \`height:${params.height}px; width: ${params.width ?? 100}%\` : ""}
RAW_BUFFERClick to expand / collapse

Feature Request: Add width parameter to [embed] directive

Problem

When using the [embed] directive in OpenClaw chat messages, the iframe renders at width: 100% of the parent container (the chat message column, ~300-400px). There is no way to control the iframe width from the directive.

Example:

This renders a 600px tall iframe but always at chat column width. For design mockups and UI prototyping, this is too narrow to be useful.

Expected behavior

The [embed] directive should accept a width parameter:

Current workaround

  • Browser CSS injection (Stylus/Violent Monkey) targeting .chat-tool-card__preview-frame or .chat-tool-card__preview-panel
  • Opening Canvas Host URL directly in a separate browser tab
  • Patching node_modules CSS

Implementation

In ui/src/ui/chat/tool-cards.ts, the renderPreviewFrame function currently only applies height inline:

function renderPreviewFrame(params: {
  title: string;
  src?: string;
  height?: number;
  sandbox?: string;
}) {
  return html\`
    <iframe
      class="chat-tool-card__preview-frame"
      title=${params.title}
      sandbox=${params.sandbox ?? ""}
      src=${params.src ?? nothing}
      style=${params.height ? \`height:${params.height}px\` : ""}
    ></iframe>
  `;
}

Adding width support would be straightforward:

style=${params.height ? \`height:${params.height}px; width: ${params.width ?? 100}%\` : ""}

Use case

Design mockup previews in chat — being able to show UI designs at appropriate desktop dimensions rather than mobile-width phone previews.

Labels

feature-request, enhancement, control-ui

extent analysis

TL;DR

To add support for controlling the iframe width in the [embed] directive, modify the renderPreviewFrame function in ui/src/ui/chat/tool-cards.ts to include a width parameter.

Guidance

  • Modify the renderPreviewFrame function to accept a width parameter in the params object.
  • Update the style attribute of the iframe to include the width parameter, using the suggested code change: style=${params.height ? \height:${params.height}px; width: ${params.width ?? 100}%` : ""}`.
  • Test the updated [embed] directive with the new width parameter to verify that it correctly sets the iframe width.
  • Consider adding validation or default values for the width parameter to ensure it is used correctly.

Example

function renderPreviewFrame(params: {
  title: string;
  src?: string;
  height?: number;
  width?: number;
  sandbox?: string;
}) {
  return html\`
    <iframe
      class="chat-tool-card__preview-frame"
      title=${params.title}
      sandbox=${params.sandbox ?? ""}
      src=${params.src ?? nothing}
      style=${params.height ? \`height:${params.height}px; width: ${params.width ?? 100}%\` : ""}
    ></iframe>
  `;
}

Notes

This solution assumes that the width parameter should be a percentage value. If a different unit (e.g. pixels) is desired, the code change will need to be adjusted accordingly.

Recommendation

Apply the suggested workaround by modifying the renderPreviewFrame function to include the width parameter, as this will provide the desired functionality without requiring a full upgrade or patch.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The [embed] directive should accept a width parameter:

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature request: Add width parameter to [embed] directive [1 participants]