I'm trying to get the simplest Material UI Select to work in React with Typescript. I spend three hours on searching for an example which shows how to set the label or placeholder (I checked all properties of the API and those are the only ones that make sense).
There's simply no demo, example, tutorial, howto, article, documentation page that puts together look and code. A billion pages with mostly extremely complex code examples, but code only. And a billion pages with demos and image. Your chance to create the first useful explanation how to use Material UI Select!
The situation is simple: My code is
import React from "react" import ReactDOM from "react-dom" import MuiSelect from '@material-ui/core/Select' import MuiMenuItem from '@material-ui/core/MenuItem' class MyComponent extends React.Component<any, MyComponentState> { constructor(props: any) { super(props); this.state = {selectedAge: ""} } render() { return <div className="container"> <MuiSelect id="offerType" label="Age" placeholder="Age" variant="outlined" value={this.state.selectedAge}> <MuiMenuItem value="1"/> </MuiSelect> </div> } } type MyComponentState = { selectedAge: string; } ReactDOM.render( <MyComponent/>, document.getElementById("root") ) The expected output is an of these
from https://material-ui.com/components/selects/
And the current output is


<>below the demo to show the code or click the pencil to edit it in code sandbox. The simplest way to do a select with a label is to use TextField.