Margin or padding inside Color doesn't use background color
See original GitHub issueA simple example:
<Color bgCyan black>
<Box padding={1}>Text here</Box>
</Color>
Expected result: Text here
at the center of a cyan box with 1 padding all around
Actual result: Text here
with cyan background, but at the center of a 1 padding black box
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Why doesn't margin get filled with background color in CSS?
Margin is providing space beyond the element's box and therefore won't be colored - it's simply space. Padding on the other hand provides...
Read more >How to change the margin color on CSS - Quora
Background color only apply to all width of that box model, so the total width of a box model = border left +...
Read more >CSS Padding vs Margin - GeeksforGeeks
Margin is completely transparent, and it does not have any background color. It clears the area around the element.
Read more >CSS margin vs. padding - LogRocket Blog
Differences between margin and padding · Spacing · Padding takes the background color; Margin doesn't · margin can be set to auto; padding...
Read more >Css/Training/padding and margin - W3C Wiki
Margin doesn't have a background color. [Syntax] margin-top: <length> | <percentage> margin-right: <length> | <percentage> margin- ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So the issue is when you have a box with padding, like
<Box padding={1}>Text</Box>
, for<Color>
component there’s nothing to color on first and third lines, because those are just empty.I’m going to leave this issue open for now, but I think when Ink is going to have support for borders, this will get solved as part of that work.
That makes sense, but also makes me think that there’s missing functionality there on
Box
. Of course, that’s probably more suited to wait until after borders go on so any color stuff can take advantage of the same boundary handling.