mui / mui/material-ui

[theme] TypeError: `theme.spacing` is not a function when using Chakra UI theme with Material UI theme & MUI X DataGrid

Open
#38,808 5 comments 2 reactions 1 assignee View on GitHub

@brijeshb42 is already working on this.

Since Sep 5, 2023.

customization: theme MUI X scope: data grid scope: system type: bug
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Steps to reproduce 🕹

Link to live example: https://codesandbox.io/p/sandbox/create-next-app-example-forked-ktl63y?file=/pages/index.js:1,1

Steps:

  1. follow this guide: https://mui.com/material-ui/guides/styled-engine/#using-with-chakra-ui to be able to use chakraui theme with mui theme.
  2. Render component from '@mui/x-data-grid'; with checkboxSelection=true prop
  3. Select one of the checkboxes
Current behavior 😯

I am getting 'typeError: theme.spacing is not a function'

typerror: theme spacing is not a fn

Expected behavior 🤔

I should be able to select/unselect rows through the checkboxes normally

Context 🔦

I have an app where the main theme used is chakraui. On one page I want to use the material ui data grid component. & I tried theme scoping and it didn't show any errors or strange ui when the table was rendered however when I tried selecting a row using the check boxes I got the error "theme.spacing is not a fn".
I have seen that theme scoping was tacked in this issue: https://github.com/mui/material-ui/issues/25852 & I have implemented the solution stated in the docs but it is not working for my case.

Your environment 🌎
npx @mui/envinfo ```
  • System:
  • OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
    
  • Binaries:
  • Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    
  • Yarn: 1.22.19 - /usr/local/bin/yarn
    
  • npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
    
  • Browsers:
  • Chrome: 113.0.5672.126
    
  • npmPackages:
  • @emotion/react: ^11.11.1 => 11.11.1 
    
  • @emotion/styled: ^11.11.0 => 11.11.0 
    
  • @mui/base:  5.0.0-beta.13 
    
  • @mui/core-downloads-tracker:  5.14.7 
    
  • @mui/material: ^5.14.0 => 5.14.7 
    
  • @mui/private-theming:  5.14.7 
    
  • @mui/styled-engine:  5.14.7 
    
  • @mui/system:  5.14.7 
    
  • @mui/types:  7.2.4 
    
  • @mui/utils:  5.14.7 
    
  • @mui/x-data-grid: ^6.12.0 => 6.12.1 
    
  • @mui/x-date-pickers: ^6.10.0 => 6.12.1 
    
  • @types/react:  18.2.21 
    
  • react: ^18.2.0 => 18.2.0 
    
  • react-dom: ^18.2.0 => 18.2.0 
    
  • typescript:  5.2.2 
    
</details>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.