import React, { useState } from
"react"
;
import { TextField } from
"@mui/material"
;
import InputAdornment from
"@mui/material/InputAdornment"
;
import { Source } from
"@mui/icons-material"
;
const data = [
{
value:
"Stack"
,
},
{
value:
"Queue"
,
},
{
value:
"Linked List"
,
},
{
value:
"Array"
,
},
];
function
App() {
const [dataStructure, setDataStructure] = useState(
"Array"
);
const handleChange = (e) => {
setDataStructure(e.target.value);
};
return
(
<center>
<div>
<h1 style={{ color:
"green"
}}>GeeksforGeeks</h1>
<h2>React MUI Text Field Input</h2>
<div style={{ maxWidth:
"98%"
}}>
<TextField
fullWidth
select
label=
"Select"
value={dataStructure}
variant=
"outlined"
onChange={handleChange}
SelectProps={{
native:
true
,
}}
helperText=
"Select a Data Structure"
InputProps={{
startAdornment: (
<InputAdornment position=
"start"
>
<Source />
</InputAdornment>
),
}}
>
{data.map((option) => (
<option key={option.value} value={option.value}>
{option.value}
</option>
))}
</TextField>
<TextField
fullWidth
select
label=
"Select"
value={dataStructure}
variant=
"filled"
style={{ marginTop: 10 }}
onChange={handleChange}
SelectProps={{
native:
true
,
}}
helperText=
"Select a Data Structure"
InputProps={{
startAdornment: (
<InputAdornment position=
"start"
>
<Source />
</InputAdornment>
),
}}
>
{data.map((option) => (
<option key={option.value}
value={option.value}>
{option.value}
</option>
))}
</TextField>
<TextField
fullWidth
select
label=
"Select"
value={dataStructure}
variant=
"standard"
style={{ marginTop: 10 }}
onChange={handleChange}
SelectProps={{
native:
true
,
}}
helperText=
"Select a Data Structure"
InputProps={{
startAdornment: (
<InputAdornment position=
"start"
>
<Source />
</InputAdornment>
),
}}
>
{data.map((option) => (
<option key={option.value}
value={option.value}>
{option.value}
</option>
))}
</TextField>
</div>
</div>
</center>
);
}
export
default
App;