Skip to content

layout: add stack component #96849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

layout: add stack component #96849

wants to merge 1 commit into from

Conversation

JonasBa
Copy link
Member

@JonasBa JonasBa commented Jul 31, 2025

I'm not entirely sure if this needs to exist, but Claude almost one shot the implementation, so I'm opening this for feedback.

The main benefit here is better semantics, and the possibility of adding a <Stack.Divider/>, otherwise this is just a convenience over <Flex direction="column"/>

With a <Stack.Divider/> component, this would look something like this, and could be a good foundation for our tab and nav components to build on

<Stack gap="md">
   <Item/>
   <Item/>
   <Item/>
   <Stack.Divider/>
   <Item/>
</Stack>

@JonasBa JonasBa requested a review from a team as a code owner July 31, 2025 14:52
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 31, 2025
@JonasBa JonasBa requested a review from a team July 31, 2025 14:57

Stack provides a focused set of layout properties: `direction` (defaults to 'column'), `gap`, `justify`, and `align`. These properties influence the layout of its children while maintaining simplicity.

Like other layout components, `Stack` inherits all spacing props like `m`, `p`, `mt`, `mb`, `ml`, `mr`, `pt`, `pb`, `pl`, `pr` and implements responsive props so that the layout can be changed per breakpoint.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be older because we don’t really have those props anymore

</Stack>
```

If a prop is not specified for a breakpoint, the value will **not** be inherited from the previous breakpoint.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we have this sentence in all layout components now, but is it really true? I thought if we do direction={{xs: 'column'', md: 'row'}}, the sm in between would be column, thus “inheriting” from xs ...

Comment on lines +8 to +25
/**
* Aligns flex items along the cross axis of the current line of flex items.
* Uses CSS align-items property.
*/
align?: Responsive<'start' | 'end' | 'center' | 'baseline' | 'stretch'>;
/**
* Sets the stack direction.
* @default 'column'
*/
direction?: Responsive<'row' | 'row-reverse' | 'column' | 'column-reverse'>;
gap?: Responsive<SpacingSize | `${SpacingSize} ${SpacingSize}`>;
/**
* Aligns flex items along the block axis of the current line of flex items.
* Uses CSS justify-content property.
*/
justify?: Responsive<
'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'left' | 'right'
>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we Pick those from Flex to keep them in sync?

Comment on lines +46 to +52
border="primary"
radius="md"
padding="md"
justify="between"
background="primary"
width="80%"
gap="md"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those props don’t exist on Stack. We really need type-checking in mdx 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI went a bit too crazy, let me clean this up. I'm going to add the Divider implementation so we can compare this a bit more in depth

@JonasBa
Copy link
Member Author

JonasBa commented Aug 6, 2025

Closing in favor of #97052

@JonasBa JonasBa closed this Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants