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

[RFC][CssVarsProvider] Ability to change shadow color on each color scheme #39144

Open
rikusen0335 opened this issue Sep 25, 2023 · 3 comments
Open
Assignees
Labels
customization: theme Centered around the theming features package: system Specific to @mui/system RFC Request For Comments

Comments

@rikusen0335
Copy link

rikusen0335 commented Sep 25, 2023

What's the problem? 🤔

Current experimental_extendTheme will accpet Partial<Record<SupportedColorScheme, ColorSystemOptions>> which is:

export interface ColorSystem {
  palette: Palette & CssVarsPalette;
  opacity: Opacity;
  overlays: Overlays;
}

But we need to set each shadow color on each color scheme light and dark (or another).

What are the requirements? ❓

Nothing

What are our options? 💡

Never thought

Proposed solution 🟢

Change type of ColorSystem to:

export interface ColorSystem {
  palette: Palette & CssVarsPalette;
  opacity: Opacity;
  overlays: Overlays;
  shadows: Theme['shadows'];
}

And thus we need to make change to generate processes?

Default approach for this was, setting shadows with theme palette mode like:

shadows: mode === 'light' ? lightShadows : darkShadows // Also component's approach is same

But this approach will not work

Resources and benchmarks 🔗

No response

@rikusen0335 rikusen0335 added RFC Request For Comments status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 25, 2023
@rikusen0335 rikusen0335 changed the title [RFC][CssVarsProvider] Ability to change shadow color on each color scheme [RFC][CssVarsProvider] Ability to change shadow color and the component color on each color scheme Sep 25, 2023
@rikusen0335 rikusen0335 changed the title [RFC][CssVarsProvider] Ability to change shadow color and the component color on each color scheme [RFC][CssVarsProvider] Ability to change shadow color on each color scheme Sep 25, 2023
@zannager zannager added package: system Specific to @mui/system customization: theme Centered around the theming features labels Sep 25, 2023
@siriwatknp
Copy link
Member

siriwatknp commented Sep 27, 2023

Before we dive into the solution, could you share the real use cases for light and dark shadows? How does it look like between light and dark mode?

@siriwatknp siriwatknp 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 Sep 27, 2023
@rikusen0335
Copy link
Author

rikusen0335 commented Sep 28, 2023

Before we dive into the solution, could you share the real use cases for light and dark shadows? How does it look like between light and dark mode?

Thank you for the reply.

Well, my use case is when using light theme, shadows are like default one, but at the same value (meant like shadows[0]) with dark theme, it should be no shadows.

We used to used this approach like doing:

const theme = createTheme({
  components: {
    MuiPaper: {
      styleOverrides: {
        root: {
          shadow: mode === 'light' ? shadows[0] : shadows[1],
        },
      },
    },
  },
});

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Sep 28, 2023
@shjacobs303
Copy link

shjacobs303 commented Jan 2, 2025

I'll add another real use case that is blocking my ability to get rid of dark mode flicker, and I think it's fairly common as the values are a pattern in MUI paid templates.

createTheme({
      colorSchemes: {
        light: {
          palette: light,
          shadows: [
            'none',
            '0 3px 6px 0 rgba(140, 152, 164, 0.25)', 
            '0 12px 15px rgba(140, 152, 164, 0.1)',
            '0 6px 24px 0 rgba(140, 152, 164, 0.125)',
            ...Array(21).fill('0 10px 40px 10px rgba(140, 152, 164, 0.175)'),
          ],
        },
        dark:
        {
          palette: dark,
          shadows: [
            'none',
            '0 3px 6px 0 rgba(0, 0, 0, 0.25)', 
            '0 12px 15px rgba(0, 0, 0, 0.1)',
            '0 6px 24px 0 rgba(0, 0, 0, 0.125)',
            ...Array(21).fill('0 10px 40px 10px rgba(0, 0, 0, 0.175)'),
          ],
        },
      },
     // ...

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 RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

4 participants