Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][AppBar] Background color is lighter than what the theme defines #41602

Open
stampycode opened this issue Mar 22, 2024 · 8 comments
Labels
bug 🐛 Something doesn't work component: app bar This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@stampycode
Copy link

stampycode commented Mar 22, 2024

Steps to reproduce

Link to live example: https://mui.com/material-ui/react-app-bar/#enable-color-on-dark

Steps:

  1. The theme sets the AppBar colour to "#1976d2".
  2. The AppBar actually has colour "#2582D6".
  3. If you change the colour to "#000" the AppBar now has colour "#171717".
  4. If your remove the color prop and set sx={{background:'#000'}} instead, the AppBar is now "#000" as expected.

I'm using the 'Digital Colour Meter' in MacOS to analyse these colours, using 'sRGB' mode.

Current behavior

The AppBar currently sets a background colour which is lighter than the selected theme colour.

There's nothing in the documentation to suggest why this is happening nor what sub-palette of "primary" the AppBar is using, nor how to make the AppBar actually use the correct colour as defined in the palette.

Expected behavior

The AppBar should be the colour defined in the palette, or the documentation should specify which sub-palette (eg. primary.something) the AppBar is using.

Context

Trying to set the theme of my MUI app to use specific colours set via theme.

Your environment

Just use the online interactive documentation, the bug exists on the live mui.com site.
https://mui.com/material-ui/react-app-bar/#enable-color-on-dark

Search keywords: AppBar Theme Color

@stampycode stampycode added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 22, 2024
@zannager zannager added the component: app bar This is the name of the generic UI component, not the React module! label Mar 22, 2024
@stampycode
Copy link
Author

It appears to be the 'backgroundImage' to blame, setting sx={{backgroundImage:'none'}} clears the problem.

@danilo-leal danilo-leal changed the title AppBar color doesnt match selected palette [material-ui][AppBar] Background color is lighter than what the theme defines Mar 22, 2024
@danilo-leal danilo-leal added the package: material-ui Specific to @mui/material label Mar 22, 2024
@ZeeshanTamboli
Copy link
Member

I see it working as expected:

issue-41602.mp4

@ZeeshanTamboli ZeeshanTamboli added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 30, 2024
@stampycode
Copy link
Author

stampycode commented Mar 30, 2024 via email

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Mar 30, 2024
@stampycode
Copy link
Author

@ZeeshanTamboli See this screenshot, the CSS shows the correct colour, the on screen colour picker shows it is not the correct colour.
image

@stampycode stampycode reopened this Mar 30, 2024
@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 30, 2024
@ZeeshanTamboli
Copy link
Member

@stampycode Apologies for not following the steps initially. This is the first time I've encountered this scenario. Isn't what's displayed in the browser's CSS correct? I'm using Windows OS, so I don't have access to a color picker tool.

If theres afilter or other element layer affecting the colour of the object on screen then the colour on screen won't match thebcss value either.

I'm unsure why there's a discrepancy between the color picker and CSS due to some "filter". However, I'll mark it as a bug.

Context

Trying to set the theme of my MUI app to use specific colours set via theme.

I'm curious why you used a color picker tool for this demo. Did you notice that the color defined in the theme wasn't being applied?

@ZeeshanTamboli ZeeshanTamboli added the bug 🐛 Something doesn't work label Mar 30, 2024
@stampycode
Copy link
Author

@ZeeshanTamboli, no problem at all! I noticed it when I saw two components next to each other that were supposed to have the same colour but were clearly different, prompting me to look harder.
For Windows I recommend this colour picker tool published by Microsoft: https://learn.microsoft.com/en-us/windows/powertoys/color-picker

If you set sx={{backgroundImage:'none'}} on the AppBar then the problem goes away - so I'm assuming the problem is that there's a partially transparent background gradient effect on the AppBar; maybe the AppBar gradient should be set to off if the background colour is applied, or if there needs to be a gradient then it should only affect the edges - the centre of the image should at least have the colour as defined by the site palette...

I understand the need for some components have colour variation for a non-flat appearance, but straying from a defined colour palette which might be corporate-mandated in many cases, without being documented, isn't helpful or obvious.

@farhanmian
Copy link

Yes, you are right, the issue is background-image: linear-gradient(rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.09))
If we remove this it's showing the correct color, So how can I fix this? Should I take a pull of the code and fix this/remove bg-img and then push the code?

[

mui.mp4

](url)

@stampycode
Copy link
Author

stampycode commented Apr 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: app bar This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

6 participants