Skip to content

fix(embedded): add box-sizing and font-size reset for embedded dashboards#38536

Open
kevin3274 wants to merge 1 commit intoapache:masterfrom
kh2u:fix/embedded-box-sizing-and-font-size
Open

fix(embedded): add box-sizing and font-size reset for embedded dashboards#38536
kevin3274 wants to merge 1 commit intoapache:masterfrom
kh2u:fix/embedded-box-sizing-and-font-size

Conversation

@kevin3274
Copy link
Copy Markdown

@kevin3274 kevin3274 commented Mar 10, 2026

User description

Summary

Embedded dashboards rendered via superset-embedded-sdk are missing CSS rules that the standalone mode gets from antd's <Layout> component via CSS-in-JS. This causes:

  1. Chart gaps disappear — missing box-sizing: border-box means padding is added outside element width, causing adjacent panels to overlap
  2. Larger fonts, less visible content — browser defaults to font-size: 16px instead of the 14px that antd's <Layout> provides in standalone mode (~14% larger)

Root Cause

In standalone mode, the component tree is:

App.tsx → RootContextProviders → <Layout> → <Layout.Content> → DashboardPage

In embedded mode, the component tree is:

embedded/index.tsx → EmbeddedContextProviders → DashboardPage

antd v5 uses CSS-in-JS with on-demand injection — component-level CSS is only injected when the component renders. Since embedded mode never renders <Layout>, the following CSS rules are never injected:

:where(.css-hash).ant-layout,
:where(.css-hash).ant-layout * {
    box-sizing: border-box;
}
.ant-layout {
    font-size: 14px;
}

Fix

Added an EmbeddedGlobalStyles component that injects the missing CSS rules using Emotion's <Global> component, using the theme's fontSize token for consistency:

  • box-sizing: border-box on *, *::before, *::after
  • font-size on body using theme.fontSize (default 14px from antd)

Related PRs

This PR extends the approach of #38351 to also fix the font-size discrepancy, which none of the existing PRs address.

Fixes #37493

Test Plan

  • Embed a dashboard using superset-embedded-sdk
  • Verify no horizontal scrollbar / chart overlap (box-sizing fix)
  • Verify font size matches standalone mode (~14px, not 16px)
  • Verify standalone dashboard rendering is unaffected
  • Verify embedded dashboard with custom theme still works

🤖 Generated with Claude Code


CodeAnt-AI Description

Restore layout box-sizing and font size in embedded dashboards

What Changed

  • Embedded dashboards now include a global CSS reset that applies box-sizing: border-box to all elements
  • The page font size in embedded mode is set to the theme's font size (matching standalone dashboards)
  • Chart panel spacing and text density in embedded dashboards match standalone rendering, preventing overlap and oversized text

Impact

✅ Restored chart gaps and spacing in embedded dashboards
✅ Consistent font size between embedded and standalone dashboards
✅ Fewer layout overlaps in embedded embeds

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

…ards

In standalone mode, antd's <Layout> component injects `box-sizing: border-box`
and `font-size: 14px` via CSS-in-JS. Embedded mode does not render <Layout>,
so these rules are never injected, causing:
1. Chart spacing/gaps to disappear (missing box-sizing)
2. Larger font rendering with less visible content (browser default 16px vs 14px)

This adds an EmbeddedGlobalStyles component that uses the theme's fontSize
token to ensure consistent rendering between standalone and embedded modes.

Fixes apache#37493
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Mar 10, 2026

Code Review Agent Run #86bca9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 87b3cf0..87b3cf0
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codeant-ai-for-open-source codeant-ai-for-open-source bot added the size:M This PR changes 30-99 lines, ignoring generated files label Mar 10, 2026
@dosubot dosubot bot added the embedded label Mar 10, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 10, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 87b3cf0
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69af929ea879a100089ae404
😎 Deploy Preview https://deploy-preview-38536--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@msyavuz
Copy link
Copy Markdown
Member

msyavuz commented Mar 11, 2026

I already have an approved pr to fix box-sizing here: #38351. Can you include the change for font-sizes on top of that? Thank you for fixing these!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing global CSS rules to embedded dashboard rendering so embedded mode matches standalone antd <Layout> defaults (fixing panel overlap from missing box-sizing and oversized text from missing font-size).

Changes:

  • Introduce EmbeddedGlobalStyles that injects a box-sizing: border-box reset for all elements in embedded mode.
  • Set embedded body font-size using the active Superset theme token (theme.fontSize) to align with standalone dashboards.
  • Render the new global styles within EmbeddedContextProviders so they inherit the correct theme.

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

embedded size/M size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard panels overlap in embedded mode due to box-sizing issue

3 participants