[Stack] Spacing overrides margin values given directly to children
See original GitHub issueWhen using a Stack
, it sets the mt
, mr
, mb
or ml
props of its children to value determined by spacing
. Unfortunately, they cannot be overrided manually:
function Component() {
return (
<Stack spacing={2}>
<Box>foo</Box>
<Box mr={100 /* Gets overrided */}>bar</Box>
<Box>baz</Box>
</Stack>
);
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
[Stack] Spacing overrides margin values given directly to ...
We'll have to check if child.props.mr || child.props.marginRight exists and use that instead of spacing value. Alternatives. You can use % ...
Read more >CSS adding margin to all children - DEV Community
Hi. I think you should drop !important rule. Like this, it will override any other margins on any child element and that is...
Read more >Space between Column's children in Flutter - Stack Overflow
I have a Column widget with two TextField widgets as children and I want to have some space ...
Read more >Spacing in CSS - Ahmad Shadeed
A better solution is to cancel the unneeded spacing by adding a negative margin to the parent element. Here is what happens.
Read more >Stack class - widgets library - Flutter - Dart API docs
A widget that positions its children relative to the edges of its box. This class is useful if you want to overlap several...
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 FreeTop 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
Top GitHub Comments
To simplify the stack component we could also use sth like this instead of cloneElement:
That way it can be easily overwritten and it would make the component more intuitive as well IMO.
Here’s a demonstration
Closing this in favor of the suggested alternative.