Skip to content

[RFC] Remove variant prop in NativeSelect #37297

Open
@ZeeshanTamboli

Description

@ZeeshanTamboli

What's the problem? 🤔

The variant prop in the Native Select does not apply any variant related styles like for the other components, such as Select or TextField.

I see that the NativeSelect is build to have a smaller bundle size if you don't need many styles. See #20436 (comment).

Developers are getting confused as to why it is not working. See the multiple issues raised:

I believe that providing an alternative solution like in #32197 (comment) even though variant prop is listed in the NativeSelect API docs does not look good. The question that arises is: what is the use of the variant prop?

What are the requirements? ❓

No response

What are our options? 💡

As an alternative, have proper styles based on the variant prop.

Proposed solution 🟢

I propose simply removing the variant prop and adding the documentation on how to support the different variants by providing a custom component using the input prop. This is a breaking change, so it should be done in the next major release.

If I am not missing something, the styles applied as shown below based on the variant seem irrelevant for the variant values (standard, outlined, filled):

...(ownerState.variant === 'filled' && {
'&&&': {
paddingRight: 32,
},
}),
...(ownerState.variant === 'outlined' && {
borderRadius: (theme.vars || theme).shape.borderRadius,
'&:focus': {
borderRadius: (theme.vars || theme).shape.borderRadius, // Reset the reset for Chrome style
},
'&&&': {
paddingRight: 32,
},
}),
.

Why are there padding and border radius styles? I guess we can remove them.

Resources and benchmarks 🔗

Also raised by @cherniavskii in #20436 (comment)

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest For Commentscomponent: selectThis is the name of the generic UI component, not the React module!package: material-uiSpecific to @mui/materialv6.x

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions