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

button css wrong when i use css varibles #43540

Open
hhniao opened this issue Aug 31, 2024 · 3 comments
Open

button css wrong when i use css varibles #43540

hhniao opened this issue Aug 31, 2024 · 3 comments
Assignees
Labels
customization: theme Centered around the theming features package: system Specific to @mui/system

Comments

@hhniao
Copy link

hhniao commented Aug 31, 2024

Steps to reproduce

the outlined button hover style wrong
https://codesandbox.io/p/sandbox/reverent-babbage-66yztk

const theme = createTheme({
  cssVariables: {
    colorSchemeSelector: ".demo-disable-transition-%s",
  },
  palette: {
    mode: "light",
    primary: {
      light: "var(--primary-light)",
      main: "var(--primary)",
      dark: "var(--primary-hover)",
      contrastText: "var(--primary-foreground)",

      // light: "#338cf5",
      // main: "#0070f3",
      // dark: "#004eaa",
      // contrastText: "#ffffff",
    },
  },
  colorSchemes: { dark: true },
});

Current behavior

No response

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: css varibles button hover

@hhniao hhniao added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 31, 2024
@hhniao hhniao closed this as completed Aug 31, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

We value your feedback @hhniao! How was your experience with our support team?
If you could spare a moment, we'd love to hear your thoughts in this brief Support Satisfaction survey. Your insights help us improve!

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 31, 2024
@oliviertassinari oliviertassinari added the package: system Specific to @mui/system label Aug 31, 2024
@aarongarciah
Copy link
Member

When enabling cssVars in the theme, we automatically generate color channel tokens (see docs). For this to work, colors must be defined in one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). We actually warn in dev when none of these formats is followed (source). We skip the warning in some cases: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/styles/createThemeWithVars.js#L424-L441

@siriwatknp can you share the reasoning to skip this warning when defining custom palettes?

@siriwatknp
Copy link
Member

@siriwatknp can you share the reasoning to skip this warning when defining custom palettes?

Because they are custom, so it can be in any structure. The warning could be seen as a false alert if your custom palette is not meant to be used with component color prop.

I think the ideal way is to let user explicitly create a palette from a function like it's created internally.

@siriwatknp siriwatknp added the customization: theme Centered around the theming features label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features package: system Specific to @mui/system
Projects
Status: In progress
Development

No branches or pull requests

4 participants