Skip to content

[RFC] Add experimental flag to use flexbox gap in Stack #33754

@siriwatknp

Description

@siriwatknp

Motivation

It would fix:

API

Adding a flag useFlexGap to Stack to switch the implementation from margin to flexbox gap:

<Stack spacing={2}>...</Stack> // '& > :not(style) + :not(style)': { marginTop: 16px };

<Stack spacing={2} useFlexGap>...</Stack> // { gap: 16px };

To switch all stacks to use gap, do it via the theme:

createTheme({
  components: {
    MuiStack: {
      defaultProps: {
        useFlexGap: true,
      }
    }
  }
})

Note: I used to think about using CSS feature query @support but it does not work for gap because the property is identical to CSS Grid gap which supports in most browser already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest For Comments.component: StackThe React component.scope: systemThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUItype: new featureExpand the scope of the product to solve a new problem.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions