-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed as not planned
Closed as not planned
Copy link
Labels
component: BoxThe React component.The React component.duplicateThis issue or pull request already exists.This issue or pull request already exists.
Description
Search keywords
Box, BoxProps
Latest version
- I have tested the latest version
Steps to reproduce
Steps:
- Setup a next app with create next-app
- Install MUI dependencies as mentioned on the installation page
- Try using Box component as following
<Box component="span">
...
</Box>
OR
Check type of BoxProps
Current behavior
As mentioned on this Changelog component prop was removed from BoxProps type as Box already has it and that we can use it when we are using it as Styled component like mentioned in the change log. This restricts using component as prop even when we use Box directly as an element.
Expected behavior
When using Box as element, we should be able to pass component prop.
Context
Rather than having to use type casting and using styled, users should be able to pass component prop when using Box directly as an element.
For reference, Stack type is as follows:
export type StackProps<
RootComponent extends React.ElementType = StackTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<StackTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType;
};
While Box type is as follows:
export type BoxProps<
RootComponent extends React.ElementType = BoxTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<BoxTypeMap<AdditionalProps, RootComponent, MaterialTheme>, RootComponent>;
Your environment
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Metadata
Metadata
Assignees
Labels
component: BoxThe React component.The React component.duplicateThis issue or pull request already exists.This issue or pull request already exists.