Add text inside the switch using material ui
I am using Material UI’s Switch component and I want to add text inside it. I want something like in the image below.
Here’s my code.
import React from 'react'; import Switch from '@material-ui/core/Switch'; export default function Switches() { const [state, setState] = React.useState({ checkedA: true, }); const handleChange = (event) => { setState({ ...state, [event.target.name]: event.target.checked }); }; return ( <div> <Switch checked={state.checkedA} onChange={handleChange} name="checkedA" inputProps={{ 'aria-label': 'secondary checkbox' }} /> </div> ); }
I already searched for the answer and found How to add text inside a Switch Component in Material-UI React? and Add text to Switch formcontrol and change it in toggle using material ui . Both of them were not helpful for me.