How to hide label from mui select in react js?
February 26, 2023Hi Friends 👋,
Welcome To aGuideHub!
To hide label from mui select in React js, you can remove label name then use this code label=""
. It will hide label from mui select in react js.
Today, I am going to show you, how to hide label from mui select in react js.
Installation
Install the following packages to use hide label of mui select in react js.
npm
npm install @mui/material @emotion/react @emotion/styled
yarn
yarn add @mui/material @emotion/react @emotion/styled
MUI material hide label from mui select example.
The below code is an example of a Material UI select. You have to import @mui material
select and use this code label=""
. It will hide label from mui select.
App.js
import * as React from 'react';
import Box from '@mui/material/Box';
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
export default function BasicSelect() {
const [age, setAge] = React.useState('');
const handleChange = (event) => {
setAge(event.target.value);
};
return (
<Box sx={{ minWidth: 120 }}>
<FormControl>
<InputLabel></InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={age}
label=""
onChange={handleChange}
style={{width: '200px'}}
>
<MenuItem value={10}>Ten</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
<MenuItem value={30}>Thirty</MenuItem>
</Select>
</FormControl>
</Box>
);
}
In the above code example, I have used the @mui/material
component and hidden label from mui select.
Check the output of the above code example.
Here, we are provided code sandbox links for the above program hide label from mui select. Then you can use whenever you want and do the changes as per your requirements.
All the best 👍