-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[system] Enable configuring the sx
prop in the theme
#35150
Conversation
@material-ui/core: parsed: +0.26% , gzip: +0.24% |
Signed-off-by: Marija Najdova <mnajdova@gmail.com>
Signed-off-by: Marija Najdova <mnajdova@gmail.com>
@@ -0,0 +1,35 @@ | |||
import { unstable_defaultSxConfig } from '@mui/system'; | |||
|
|||
const sxConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For comparison, this is how it looked previously: https://github.com/mui/material-ui/blob/1c897f813aea4f3293270071aa3851cc214e0da9/packages/mui-joy/src/styles/styleFunctionSx.ts
docs/data/system/experimental-api/extend-sx-prop/ChangeTheBehaviorSxProp.tsx
Outdated
Show resolved
Hide resolved
docs/data/system/experimental-api/extend-sx-prop/extend-sx-prop.md
Outdated
Show resolved
Hide resolved
docs/data/system/experimental-api/extend-sx-prop/ChangeTheBehaviorSxProp.tsx
Outdated
Show resolved
Hide resolved
docs/data/system/experimental-api/extend-sx-prop/ChangeTheBehaviorSxProp.tsx
Outdated
Show resolved
Hide resolved
docs/data/system/experimental-api/extend-sx-prop/ExtendTheSxProp.tsx
Outdated
Show resolved
Hide resolved
docs/data/system/experimental-api/extend-sx-prop/extend-sx-prop.md
Outdated
Show resolved
Hide resolved
@@ -469,6 +469,8 @@ const Button = React.forwardRef(function Button< | |||
tabIndex, | |||
type, | |||
variant, | |||
// required for making sure the sx prop is handled correctly | |||
materialYouComponent: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think of Material You as a separate library similar to Joy UI. Then add a doc similar to https://mui.com/joy-ui/guides/using-joy-ui-and-material-ui-together/ that guides how to use MD3 in the existing MD2 project.
I have tried the implications of this PR in the Joy UI + Material UI demos, e.g. https://codesandbox.io/s/material-ui-feat-joy-ui-forked-z9bv90?file=/demo.tsx. It seems to mostly work like before, only that the sx behavior is linked to the theme config, so based on the last theme that is deep merged.
It's a bit sad though that we can't have a different emotion context. I had a friend who recently asked me about using Joy UI inside an existing Material UI app (an engineer without a front-end background). He was intimidated by the size of the examples, he didn't try 🙃.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great step froward for MUI System 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 The implementation looks good to me.
docs/data/system/pages.ts
Outdated
pathname: '/system/experimental-api/extend-sx-prop', | ||
title: 'Extend the `sx` prop', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pathname: '/system/experimental-api/extend-sx-prop', | |
title: 'Extend the `sx` prop', | |
pathname: '/system/experimental-api/sx-config', | |
title: 'sx config', |
How about renaming the page to sx config
or configure sx prop
and grouping these into the page:
- override the default config (from
Override some of the existing behavior
) - add your own config (from
Extend the sx prop
) - API
cc @samuelsycamore might have a better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, "Configure the sx prop" sounds better, as the page is both about extending and changing. Updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section should be updated or removed. https://deploy-preview-35150--material-ui.netlify.app/material-ui/customization/theme-components/#the-sx-syntax-experimental
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com> Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> Signed-off-by: Marija Najdova <mnajdova@gmail.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> Signed-off-by: Marija Najdova <mnajdova@gmail.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> Signed-off-by: Marija Najdova <mnajdova@gmail.com>
…op.tsx Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> Signed-off-by: Marija Najdova <mnajdova@gmail.com>
…viorSxProp.tsx Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> Signed-off-by: Marija Najdova <mnajdova@gmail.com>
…viorSxProp.tsx Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> Signed-off-by: Marija Najdova <mnajdova@gmail.com>
I've updated it to use the |
@samuelsycamore this should be ready for final review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Text looks good! Just left one final comment with grammar suggestions.
docs/data/system/experimental-api/configure-the-sx-prop/configure-the-sx-prop.md
Outdated
Show resolved
Hide resolved
…ure-the-sx-prop.md Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com> Signed-off-by: Marija Najdova <mnajdova@gmail.com>
sx
mappings in the theme
sx
prop in the theme
Breaking changes
Changes in the experimental API:
This PR changes the way the
sx
props works, by defining a config inside the theme for each key supported. This allows us to offer extensibility of the functionality of thesx
prop, as well as overrides for some of its behavior. There shouldn't be any changes of the behavior.Related to #30725 (it is now possible for this to be done in userland).
Fixes #32734, fixes #33525, fixes #33281
Docs preview: https://deploy-preview-35150--material-ui.netlify.app/system/experimental-api/configure-the-sx-prop/
Examples:
We are going to export the default sx config, so that people can compose it with their custom logic.