Skip to content

[system] Negative spacing produces invalid CSS for calc() and clamp() values in a spacing array #49897

Backlog

Description

@PANJA-ABHISHEK

Steps to reproduce

import { createTheme } from '@mui/material/styles';

const theme = createTheme({
  spacing: [0, 'clamp(0.5rem, 1vw, 1rem)', 'calc(1rem + 2px)'],
});

theme.spacing(-1);
// <Box sx={{ mt: -2 }} />

Current behavior

  • theme.spacing(-1) returns -clamp(0.5rem, 1vw, 1rem)
  • sx={{ mt: -2 }} gives margin-top: -calc(1rem + 2px)

A - in front of a CSS function is not valid CSS, so the browser drops the declaration and the negative margin is not applied.

Expected behavior

calc(-1 * clamp(0.5rem, 1vw, 1rem)) and calc(-1 * calc(1rem + 2px)), the same way a var() value is already negated.

Context

For a spacing array and a negative value, createBaseUnit in packages/mui-system/src/spacing/spacing.ts returns -${value} for strings. #45550 added calc(-1 * …) for values that start with var(, but other CSS functions (calc(), clamp(), min(), max()), which are common in fluid spacing scales, still get the - prefix.

Your environment

@mui/system on master (a4f20c2).

Search keywords: spacing array negative clamp calc

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