Replies: 2 comments
-
Some initial thoughts, perhaps we are missing a layout primitive that would handle this? By adding |
Beta Was this translation helpful? Give feedback.
-
I like this description of what Box is meant to be. I'm not sure we're missing a primitive but perhaps these could be props to on our layout components vs on Box itself. I could see I'd like to make sure we have a definitive use case for adding this kind of feature to these components before going ahead with this though |
Beta Was this translation helpful? Give feedback.
-
TL;DR
Should we add a
display
prop to some of our components so that they can set their outer layout?Context
HTML elements have two display types: inner and outer. Inner display types set the layout of an element's children (ex.
grid
andflex
). Our new foundational layout components seem to mostly deal with setting the component's children (ex.Inline
,Grid
,Tiles
)Outer display types set the layout of the element itself (ex.
inline
andblock
). Right now, we're not able to set the outer display type of our components. There are also precomposed display types that set the inner and outer properties togetherdisplay: inline-flex
. You can also use the syntaxdisplay: inline flex
, but this is not well supported in all browsers just yet.So, the question is: do we think we'll need or want to be able to set an element's outer display type directly?
Prototype
I prototyped allowing a
display
property on theBox
components to set thedisplay
CSS property on this branch. I copied a list of all display values, but if we want to allow this prop then I think we can narrow this down only to the outer display types. This will mean that users will still need to use the new Layout components in most cases.Something more like this:
Background
I stumbled on this question while trying to rebuild the
Tag
components using our new layout components. TheTag
components can render a few different ways: as a<span>
with nesteda
orspan
children and an optional inlinebutton
child. Or it can return abutton
.The
Tag
is currently styled usingdisplay: inline-flex
, which sets both the outer and inner display type for the rendered element. Trying to recreate this solution using theInline
andBox
components andspan
isn't working because we can't set the height of an inline element.span
rendered fromBox
button
rendered insidespan
This led me down the rabbit hole of of inner and outer display types described above.
Beta Was this translation helpful? Give feedback.
All reactions