mui / mui/material-ui

[system] `maxWidth='xs'` is applied inconsistently, cannot be configured

Open
#34,646 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component: Box docs scope: system
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Steps to reproduce 🕹

Sandbox Link

Current behavior 😯

setting maxWidth='xs' has different effects on different components.

Component Compiled CSS
<Container maxWidth='xs' /> { max-width: 444px }
<Dialog maxWidth='xs' /> { max-width: 444px }
<Box maxWidth='xs' /> { max-width: xs }
... Everything else { max-width: xs }

There are three issues with this behavior:

  1. xs is not a valid CSS value.
  2. As xs is a breakpoint with the value of 0, both 444px and xs are semantically incorrect.
  3. The value 444px is not configurable.
Expected behavior 🤔

Ideally, every use of maxWidth='xs' should apply this value of 444px.

This fallback value should also be configurable. Currently, to achieve the same behavior, you need to overwrite the xs breakpoint in a custom theme to be 444px, which would then cause issues with xs media queries and so on.

Context 🔦

I'm trying to cleanly refactor a component away from from using a container. Currently I'm using a custom css class to work around this.

Here are the implementations of the 444 value.

Your environment 🌎
npx @mui/envinfo
  System:
    OS: macOS 12.5.1
  Binaries:
    Node: 14.15.1 - ~/.asdf/installs/nodejs/14.15.1/bin/node
    Yarn: Not Found
    npm: 6.14.8 - ~/.asdf/installs/nodejs/14.15.1/bin/npm
  Browsers:
    Chrome: 105.0.5195.125
    Edge: Not Found
    Firefox: 105.0.1
    Safari: 15.6.1
  npmPackages:
    @emotion/react: ^11.10.4 => 11.10.4
    @emotion/styled: ^11.10.4 => 11.10.4
    @mui/base:  5.0.0-alpha.98
    @mui/core-downloads-tracker:  5.10.6
    @mui/material: ^5.10.6 => 5.10.6
    @mui/private-theming:  5.10.6
    @mui/styled-engine:  5.10.6
    @mui/system:  5.10.6
    @mui/types:  7.2.0
    @mui/utils:  5.10.6
    @types/react: ^18.0.21 => 18.0.21
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0
    typescript: ^4.8.3 => 4.8.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the maxWidth handling in mui-system/src/Container/createContainer.tsx and mui-material/src/Dialog/Dialog.js, then use the linked CodeSandbox to inspect how Box and other components behave. Done means maxWidth='xs' produces a consistent value across components and the 444px fallback can be configured without changing the xs breakpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.