Skip to content

Add <Stack> (a variant of <Flex>)#52003

Merged
ravicious merged 1 commit intomasterfrom
r7s/stack
Feb 11, 2025
Merged

Add <Stack> (a variant of <Flex>)#52003
ravicious merged 1 commit intomasterfrom
r7s/stack

Conversation

@ravicious
Copy link
Copy Markdown
Member

This PR adds a Flex variant called Stack. It's basically just <Flex flexDirection="column" alignItems="flex-start">. Over time, I found myself reaching for it pretty often, especially in the new VNet diagnostic report that I'm working on. It gets pretty annoying to define it by hand whenever you want to use it, hence this PR.

It's based on The Stack from Every Layout:

Flow elements require space (sometimes referred to as white space) to physically and conceptually separate them from the elements that come before and after them. This is the purpose of the margin property.

However, design systems conceive elements and components in isolation. At the time of conception, it is not settled whether there will be surrounding content or what the nature of that content will be. One element or component is likely to appear in different contexts, and the requirement for spacing will differ.

We are in the habit of styling elements, or classes of elements, directly: we make style declarations belong to elements. Typically, this does not produce any issues, but margin is really a property of the relationship between two proximate elements. (…)

The trick is to style the context, not the individual element(s). The Stack layout primitive injects margin between elements via their common parent.

I've used gap instead of margin-block like Every Layout does because 1) it's what we already use 2) it has wider browser support.

Basic example Example with margin-top: auto
stack-basic stack-margin-auto

@ravicious ravicious added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Feb 10, 2025
@ravicious ravicious changed the title Add <Stack> (a variant of <Flex>`) Add <Stack> (a variant of <Flex>) Feb 10, 2025
Comment thread web/packages/design/src/Flex/Flex.tsx Outdated
Copy link
Copy Markdown
Contributor

@avatus avatus left a comment

Choose a reason for hiding this comment

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

YESSSS

@ravicious ravicious enabled auto-merge February 11, 2025 09:29
@ravicious ravicious added this pull request to the merge queue Feb 11, 2025
Merged via the queue into master with commit 5f8b5f6 Feb 11, 2025
@ravicious ravicious deleted the r7s/stack branch February 11, 2025 09:46
@public-teleport-github-review-bot
Copy link
Copy Markdown

@ravicious See the table below for backport results.

Branch Result
branch/v17 Create PR

@public-teleport-github-review-bot
Copy link
Copy Markdown

@ravicious See the table below for backport results.

Branch Result
branch/v16 Failed
branch/v17 Failed

carloscastrojumo pushed a commit to carloscastrojumo/teleport that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants