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

[docs] Add a note about minimal required version for theme merging to the guides #36973

Merged
merged 4 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Additionally, keep these in mind when using them together:
- Both of them use [MUI System](/system/getting-started/overview/) as their style engine, which uses React context for theming.
- Theme scoping must be done on one of the libraries.

## Prerequisite

- Have `@mui/material` and `@mui/joy` installed in your project.
- The version of both libraries must be [v5.12.0](https://github.com/mui/material-ui/releases/tag/v5.12.0) or higher.

## Set up the providers

Render Material UI's `CssVarsProvider` inside Joy UI's provider and use `THEME_ID` to separate the themes from each other.
Expand Down
6 changes: 5 additions & 1 deletion docs/data/material/guides/styled-engine/styled-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ This package-swap approach is identical to the replacement of React with [Preact
Having more than one styling libraries could introduce unnecessary complexity to your project. You should have a very good reason to do this.
:::

Material UI can coexist with other libraries that depend on emotion or styled-components. To do that, render Material UI's `ThemeProvider` as an inner provider and use the `THEME_ID` to store the theme.
Material UI, starting from [v5.12.0](https://github.com/mui/material-ui/releases/tag/v5.12.0), can coexist with other libraries that depend on emotion or styled-components. To do that, render Material UI's `ThemeProvider` as an inner provider and use the `THEME_ID` to store the theme.

```js
import { ThemeProvider, THEME_ID, createTheme } from '@mui/material/styles';
Expand All @@ -141,6 +141,10 @@ function App() {

The theme of Material UI will be separated from the other library, so when you use APIs such as `styled`, `sx` prop, and `useTheme`, you will be able to access Material UI's theme like you normally would.

### Minimum version

[Theme scoping](https://github.com/mui/material-ui/pull/36664) has been added to Material UI v5.12.0, so be sure you're running at that version or higher.

### Using with [Theme UI](https://theme-ui.com/)

Render Material UI's theme provider below Theme UI's provider and assign the material theme to the `THEME_ID` property.
Expand Down