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

[data grid] Tweak GridRootStyles to allow CSS variables (and joy-ui!) #6083

Open
adammanderson opened this issue Sep 8, 2022 · 7 comments
Open
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! design: joy This is about Joy Design, please involve a visual or UX designer in the process design This is about UI or UX design, please involve a designer new feature New feature or request

Comments

@adammanderson
Copy link

adammanderson commented Sep 8, 2022

Current behavior 😯

Error:
Uncaught Error: MUI: Unsupported 'var(--joy-palette-neutral-800)' color. The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().

Cause:
const borderColor = theme.palette.mode === 'light' ? lighten(alpha(theme.palette.divider, 1), 0.88) : darken(alpha(theme.palette.divider, 1), 0.68);

Expected behavior 🤔

MuiDataGrid should support CSS variables.

Steps to reproduce 🕹

  1. Set theme.palette.divider as a CSS variable.
  2. Watch GridRootStyles explode.
  3. Make bug.

Context 🔦

It would be great to get MuiDataGrid working with joy-ui and/or custom css variables.

Your environment 🌎

No response

Order ID 💳 (optional)

No response

@adammanderson adammanderson added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 8, 2022
@adammanderson
Copy link
Author

Anyone wanting to use DataGrid inside a @mui/joy project, a workaround could be to use a nested theme. Make sure to set up material in your joy project first: https://mui.com/joy-ui/guides/using-joy-ui-and-material-ui-together/#case-b-material-ui-in-a-joy-ui-project. Then:

import { CssVarsProvider } from '@mui/joy';
import { ThemeProvider } from '@mui/material';
import { DataGrid } from '@mui/x-data-grid';
import { createTheme } from '@mui/material/styles';

const dataGridTheme = createTheme();

<CssVarsProvider theme={theme}>
  ...
  <ThemeProvider theme={dataGridTheme}>
    <DataGrid ... />
  </ThemeProvider>
  ...
</CssVarsProvider>

@m4theushw
Copy link
Member

Thanks for expressing interest in using the DataGrid with Joy. We're aware of this problem and we need to discuss yet how to support it properly.

@m4theushw m4theushw added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 10, 2022
@m4theushw m4theushw moved this to 🆕 Needs triage in MUI X Data Grid Sep 10, 2022
@0xc00010ff
Copy link

Great workaround @adammanderson.
Would love support for this. ✋ Will buy the Pro version when this is implemented.
Thanks for the great components, MUI team.

@cherniavskii
Copy link
Member

For the Material UI's CSS Theme Variables - it works with the DataGrid: https://codesandbox.io/s/floral-wind-nok8wk?file=/demo.tsx
The issue is when you use a regular theme and set the palette color to a CSS variable: https://codesandbox.io/s/unruffled-frog-i6ilvi?file=/demo.tsx

@cherniavskii
Copy link
Member

We might consider using CSS filters instead of lighten/darken JS functions for color manipulation.

@cherniavskii cherniavskii added the design: joy This is about Joy Design, please involve a visual or UX designer in the process label Jan 31, 2023
@cherniavskii cherniavskii moved this from 🆕 Needs refinement to 📋 Backlog in MUI X Data Grid Jan 31, 2023
@oliviertassinari oliviertassinari added the design This is about UI or UX design, please involve a designer label Sep 25, 2023
@atillaaliyev
Copy link

Hi,
I don't understand result of discuss. Can we use DataGrid and Joy together? I don't see any documents about it.
We will recode all components from Material UI to Joy and we will re-design them. In additional we will renew our premium license and want to use Joy and DataGrid7 together.

@atillaaliyev
Copy link

use a regular theme and set the palette color to a CSS varia

Hi,
I tried for this : https://codesandbox.io/p/sandbox/floral-wind-nok8wk?file=%2Fdemo.tsx . When I changed CSS Provider from '@mui/joy' , i get this error.

image
image

@oliviertassinari oliviertassinari changed the title Tweak GridRootStyles to allow CSS variables (and joy-ui!) [data grid] Tweak GridRootStyles to allow CSS variables (and joy-ui!) Sep 1, 2024
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: data grid This is the name of the generic UI component, not the React module! design: joy This is about Joy Design, please involve a visual or UX designer in the process design This is about UI or UX design, please involve a designer new feature New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

6 participants