Bug: `sx` background not applied on Card/Accordion: Theme paints an opaque background-image
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- frontend, testing-qa
Research direction
Start with createDiamondOverlays() and trace how its overlays values reach Paper-derived components through ThemeProvider. Reproduce the Card example in a browser, then verify the elevation guard and MuiAutocomplete.paper behavior while preserving the existing tokens. Done means sx background colors are visible across the listed components, with a browser pixel check covering the painting behavior.
Written by the indexing model from the issue text.
Description
Bug Report
Summary
sx={{ bgcolor: ... }} has no visible effect on Card or Accordion under SRU's ThemeProvider. The style is applied, but the theme paints an opaque background-image over it, and background-image always paints above background-color.
Affects every Paper-derived component at elevation > 0: Card, Accordion, Dialog, Menu, Popover, AppBar, SnackbarContent.
Expected behaviour
<Card sx={{ bgcolor: "primary.container" }}> renders with that background.
Actual behaviour
Renders the theme's elevation surface colour. The sx background is invisible and cannot be overridden by specificity or !important — it's painting order, not cascade.
Steps to reproduce
- Wrap an app in SRU's
ThemeProvider. - Render
<Card sx={{ bgcolor: "rgb(255,0,0)" }}>test</Card>. - Card is not red.
B is red, A is not:
<Card sx={{ bgcolor: "rgb(255,0,0)" }}>A</Card>
<Card sx={{ bgcolor: "rgb(255,0,0)", backgroundImage: "none" }}>B</Card>
Environment
- Package version: 0.7.1 (introduced in
aea9988/ #269; not in 0.6.x) - MUI: reported on 7.3.10; peer range is
^7.0.0 - Browser/OS: all — specified CSS painting behaviour
Additional context
Cause: createDiamondOverlays() fills MUI's overlays slot with opaque --ds-elevation-* hexes, both modes. Paper renders it as backgroundImage. That slot expects a translucent film; an opaque value hides everything beneath.
Wider impact: also covers our own colours as MuiSnackbarContent.root has never rendered, and disabled Accordion loses action.disabledBackground.
Fix: paint as background-color instead, tokens unchanged. Guard to elevation > 0 (or Alert breaks), and convert MuiAutocomplete.paper, which uses overlays[8] deliberately.
Tests won't catch it: they check the theme object, not output. jsdom can't see it either as the colour is in computed styles, just painted over. Needs a browser pixel check.
Workarounds: variant="outlined", elevation={0}, sx={{ backgroundImage: "none" }}.
Out of scope: borderRadius issue reported alongside is MUI specificity, not this bug.
- Dominant language
- TypeScript
- Stars
- 9
- Forks
- 3
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 20
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from DiamondLightSource/sci-react-ui
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
DiamondLightSource/sci-react-ui#325 · 1 comment ·
Maintainers usually reply within 2 days
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
DiamondLightSource/sci-react-ui#283 ·
Maintainers usually reply within 2 days
-
needs-triage
Difficulty 3/5 1-2 days Newbie friendliness 65/100
DiamondLightSource/sci-react-ui#334 ·
Maintainers usually reply within 2 days
-
needs-triage
Difficulty 5/5 Over a week Newbie friendliness 38/100
DiamondLightSource/sci-react-ui#332 ·
Maintainers usually reply within 2 days
-
needs-triage
Difficulty 5/5 Over a week Newbie friendliness 35/100
DiamondLightSource/sci-react-ui#331 ·
Maintainers usually reply within 2 days
All issues in DiamondLightSource/sci-react-ui
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Doist/todoist-cli#576 ·
Maintainers usually reply within 1 day
-
🐛 Bug supabase/cli
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CopilotKit/aimock#491 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
agilepathway/label-checker#710 · 2 comments ·
Maintainers usually reply within 1 day