mui / mui/material-ui

`sx` prop ignores CSS variable with a valid empty-space as value

Open
#46,609 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

customization: css external dependency scope: system waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/github-f4qof1vl?file=src%2FApp.tsx
  2. 2 <Box> elements are in the page, and both are expected to have a green background
Current behavior

Only the second <Box> has a green background. it uses style attributeinstead ofsx` prop

Expected behavior
<Box sx={{ '--c': ' ' }}> />

should translate to

<div style="--c: ;"></div>
Context
Image

https://css-tricks.com/the-css-custom-property-toggle-trick

Your environment

No response

Search keywords: empty space value

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 with src/App.tsx in the linked StackBlitz example and compare the Box using sx with the one using the style attribute. Done when the sx value '--c': ' ' produces the equivalent div style of --c: ; and the reproduction behaves consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.