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

Best workaround to work with CSS variable which are not supported yet #27990

Closed
volta-vianney opened this issue Aug 27, 2021 · 1 comment
Closed
Labels
docs Improvements or additions to the documentation package: styled-engine Specific to @mui/styled-engine

Comments

@volta-vianney
Copy link

volta-vianney commented Aug 27, 2021

Hello,
I've seen in the backlog that CSS variable are coming to material ui v5.
I'm migrating all my application from rmwc to Material ui and I really don't know what is the best way to handle these CSS variable since they are not supported.

This is the kind of theme I have in my app :


const useStyles = createUseStyles({
  theme: {
    '--background-color': '#000000',
    '--foreground-color': '#ffffff',
    '--primary-color': '#141c4e',
    '--secondary-color': '#1aa3ff',

    '--inactive-color': '#222222',

    '--non-dispersed-color': '#00ffff',
    '--dispersed-color': '#ff9900',

    '--stability-level-1-color': '#1d7bc4',
    '--stability-level-2-color': '#ffffff',
    '--stability-level-3-color': '#ffff00',
    '--stability-level-4-color': '#ff9900',
  },
  fill: {
    width: '100vw',
    height: '100vh',

    display: 'flex',

    background: `var(--background-color)`,
    color: `var(--foreground-color)`,
  },
});

Thanks for the help

@volta-vianney volta-vianney added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 27, 2021
@eps1lon eps1lon added docs Improvements or additions to the documentation package: styled-engine Specific to @mui/styled-engine and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 10, 2021
@eps1lon
Copy link
Member

eps1lon commented Sep 10, 2021

We simply don't support CSS variables at the moment for color values since we compute certain colors on the fly based on the theme colors. This isn't possible with variables at the moment.

See #27651 for planned support.

@eps1lon eps1lon closed this as completed Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: styled-engine Specific to @mui/styled-engine
Projects
None yet
Development

No branches or pull requests

2 participants