Description
Describe the issue
During freeCodeCamp/freeCodeCamp#52092, I found that the ui-components
buttons don't automatically space out when they stack on top of each other, and the library also doesn't have a prop or a component to handle this sort of arrangement.
Comparison:
Bootstrap | ui-components |
---|---|
![]() |
![]() |
To unblock the migration, I temporarily used the Spacer
component in /learn to manually add a gap between the buttons (see freeCodeCamp/freeCodeCamp#52577).
Solution
Some approaches off the top of my head:
- Mimic Bootstrap implementation and add spacing logic to the Button component
- Build a new component component in
ui-components
that handles layout arrangement, including direction (vertical and horizontal) and content spacing
My thoughts:
I'm personally against (1). I think atomic components such as Button should be made as dumb as possible, and they shouldn't be aware of their layout context to compute their styles.
That leaves me with option (2). I would call this new component Container
as the described responsibilities fit the name. However, we already have a Container
component in ui-components
, which at the moment is just a wrapper that controls width and pads its content. So we would need to either find a new name for this component or update Container
to support these capabilities.
References
How Bootstrap handles the button spacing: https://github.com/twbs/bootstrap/blob/f17f882df292b29323f1e1da515bd16f326cee4a/less/buttons.less#L156-L159