Replies: 1 comment 1 reply
-
Consider using the Stack component instead |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
A new property on elements such as
<Box>
that applies margin spacing to direct childrenProblem Statement/Justification
Sometimes, you find yourself in a situation where you would like to add some spacing for all elements inside a
<Box>
or another wrapper element. For example, given the following code example.Here I would like the all the
<MyOwnComponet />
inside my<Box>
in theapp.jsx
file to have a spacing of16px
or4 chakra units
. There a couple of solutions here<MyOwnComponent/>
to have something likemt={4}
and then_first={{mt: 0}}
- But this has a couple of drawbacks, for example if I dont want the margin top to always be there in other pages. Adding a margin like this feels pretty bad in my opinion and usually just results in needing to pass in some prop to disable the margin, and then maybe you find yourself in a situation where you would like to have more margin in some pages and then this just starts to get a bit out of hand.<Box>
that is wrapping my 3<MyOwnComponet />
in a<Flex>
with aflexDir="column"
and then addgap={4}
- This would solve the issue and is a pretty common approach, but also might not be the best thing ever as changing the wrapper to a flex could effect the layout of the elements inside and have some unwanted side-effects. But that is pretty uncommon.Proposed Solution or API
Adding a new property to the standard Chakra components that is heavily inspiread by the space utils from Tailwind.css.
In the code below I would like the
spaceY
(and also aspaceX
) property to be addedHere is a proposed CSS output (given that the box's generated class name is
abc123
)Alternatives
No response
Additional Information
I would gladly take this on and provide a PR if you want :)
Beta Was this translation helpful? Give feedback.
All reactions