Skip to content

fix: prevent margin collapse between consecutive cell outputs#8215

Merged
mscolnick merged 1 commit intomarimo-team:mainfrom
AhmadYasser1:fix/markdown-cell-margin-gap
Feb 10, 2026
Merged

fix: prevent margin collapse between consecutive cell outputs#8215
mscolnick merged 1 commit intomarimo-team:mainfrom
AhmadYasser1:fix/markdown-cell-margin-gap

Conversation

@AhmadYasser1
Copy link
Contributor

Summary

Consecutive markdown cell outputs had less vertical spacing than content within a single cell due to CSS margin collapsing. Wrapping the output container in flex flex-col prevents margin collapsing between siblings.

Closes #3063

Test Plan

  • Visual: consecutive mo.md() cells now have consistent spacing
In run mode, consecutive markdown cell outputs have slightly less
vertical spacing than content within a single markdown cell. This
happens because CSS margin collapsing merges the bottom margin of
one cell output with the top margin of the next.

Wrapping rendered cells in a flex column container prevents margin
collapse, ensuring the full 1rem + 1rem spacing between adjacent
cell outputs is preserved. The explicit gap-5 for the "show code"
variant is conditionally applied on the same container.

Fixes marimo-team#3063
@mscolnick mscolnick requested a review from Copilot February 10, 2026 03:07
@mscolnick mscolnick added the bug Something isn't working label Feb 10, 2026
Copy link
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

Fixes inconsistent vertical spacing between consecutive markdown cell outputs by preventing CSS margin collapsing in the vertical layout renderer.

Changes:

  • Always wrap rendered cells in a flex flex-col container to prevent margin collapsing between sibling outputs.
  • Keep the existing inter-cell gap-5 spacing behavior when code is shown (conditional on showCode && canShowCode).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mscolnick mscolnick merged commit 3b3f363 into marimo-team:main Feb 10, 2026
34 of 35 checks passed
@AhmadYasser1 AhmadYasser1 deleted the fix/markdown-cell-margin-gap branch February 10, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

3 participants