Skip to content

[system] maxWidth throws or returns an invalid value when the theme has no breakpoint unit #49895

Backlog

Description

@PANJA-ABHISHEK

Steps to reproduce

import { sizing } from '@mui/system';

sizing({ maxWidth: 'sm' });
sizing({ maxWidth: 'md', theme: { breakpoints: { values: { md: 900 } } } });

Current behavior

  • Without a theme: TypeError: Cannot read properties of undefined (reading 'breakpoints')
  • With a theme whose breakpoints has no unit: { maxWidth: '900undefined' }, which is not valid CSS.

Expected behavior

  • { maxWidth: 600 }, from the default breakpoints (the function already falls back to them when the theme has no value for the key)
  • { maxWidth: 900 }

Context

maxWidth in packages/mui-system/src/sizing/sizing.ts reads the breakpoint value with optional chaining and falls back to the default breakpoints, so it is meant to work without a full theme. The unit check right after it doesn't:

if (props.theme?.breakpoints?.unit !== 'px') {
  return { maxWidth: `${breakpoint}${props.theme.breakpoints.unit}` };
}

When there is no unit, the condition is true and it reads props.theme.breakpoints.unit anyway. The rest of the system treats breakpoint values without a unit as px.

Your environment

@mui/system on master (a4f20c2).

Search keywords: sizing maxWidth breakpoints unit

Search keywords:

Activity

  1. added
    status: waiting for maintainer
    on Nov 24, 2026
  2. added
    scope: system
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: systemstatus: waiting for maintainer

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions