[system] `maxWidth='xs'` is applied inconsistently, cannot be configured
Nobody has claimed this yet.
- 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 🕹
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:
xsis not a valid CSS value.- As
xsis a breakpoint with the value of0, both444pxandxsare semantically incorrect. - The value
444pxis 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.
- mui-system/src/Container/createContainer.tsx Line 115
- mui-material/src/Dialog/Dialog.js Line 127, 130
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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