I am trying to set the MUI Select
component's width. For this I have to provide a class to the FormControl
component, such as mw-120
which links to a CSS class defining the min-width
of 120px.
Material UI Select component:
<FormControl className='mw-120'>
<InputLabel htmlFor='selected-language'>Language</InputLabel>
<Select value={this.state.selectedLanguage}
onChange={(e) => this.onLanguageChange(e.target.value)}
inputProps={{
name: 'language',
id: 'selected-language',
}}>
{menuItems}
</Select>
</FormControl>
CSS class:
.mw-120 {
min-width: 120px;
}
While I would expect the size of the Select
component to now have a width of 120px minimum, the component remains exactly the same after rendering, as shown in the following picture. In other words, it is to narrow. The width is not big enough. The width should be greater than the label Language
.
An element analysis within the Chrome Developer Tools has shown that the main DIV element of that component has a class .MuiFormControl-root-234
that contains min-width: 0;
, and it is located/ranked higher than my .mw-120
class. I guess this overrides my .mw-120
class, right? Is there any other way to influence the width of the Material UI Select component? There are no helpful examples of influencing the width of this component on the Material UI Select component page.