You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should we be able to provide styleOverrides, defaultProps or variants for Box?
The issue is present in the latest release.
I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
I'm not sure if this is a bug, or if it's by design. Considering the flexibility of Box I can see where it might be difficult to do.
We've been making extensive use of the ability to declare our own variants for various mui components and have found it to be more desirable than dealing with classNames.
One component that doesn't seem to work with this model, however, is Box.
I've searched the existing issues as best I can but keep coming up empty, and haven't seen anyone else discussing Box variants. I'm hoping I've just missed something.
I've also tried with other props such as data-variant="error", in case it's just that Box doesn't recognize 'variant'.
Expected Behavior 🤔
MuiBox variants, defaultProps and styleOverrides should work as they do with other components.
Steps to Reproduce 🕹
While working on setting up this codebox, I noticed that MuiBox is not present in components.d.ts, so I guess this is more of a feature request than a bug report :-/
Thanks for reporting about this. Currently, Box is meant to be used in a specific location. It is useful when you have to define a small stylesheet on it such as a flexbox wrapper.
I guess in your case, you should create a new component with styled and define variant prop by yourself. I think this is worth creating a doc about how to create a new themable component with MUI styled.
Thanks @siriwatknp. Yeah, we currently used styled to create a number of variations based on Box. I was attempting to consolidate all these into a single place as we're able to do with every other mui component (so far). Box does appear to be an outlier.
At the moment I'm exploring using Container for this instead, though I suspect that has too much overhead. Having Box support variants and styleOverrides would be the ideal solution for us.
Should we be able to provide styleOverrides, defaultProps or variants for Box?
Current Behavior 😯
I'm not sure if this is a bug, or if it's by design. Considering the flexibility of Box I can see where it might be difficult to do.
We've been making extensive use of the ability to declare our own variants for various mui components and have found it to be more desirable than dealing with classNames.
One component that doesn't seem to work with this model, however, is Box.
I've searched the existing issues as best I can but keep coming up empty, and haven't seen anyone else discussing Box variants. I'm hoping I've just missed something.
Here's a simplified example:
I've also tried with other props such as
data-variant="error"
, in case it's just that Box doesn't recognize 'variant'.Expected Behavior 🤔
MuiBox variants, defaultProps and styleOverrides should work as they do with other components.
Steps to Reproduce 🕹
While working on setting up this codebox, I noticed that MuiBox is not present in components.d.ts, so I guess this is more of a feature request than a bug report :-/
https://codesandbox.io/s/heuristic-water-pzsoz
The text was updated successfully, but these errors were encountered: