File size: 811 Bytes
4114d85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import { useState } from 'react'
import PropTypes from 'prop-types'
import { FormControl, Switch } from '@mui/material'
export const SwitchInput = ({ value, onChange, disabled = false }) => {
const [myValue, setMyValue] = useState(!!value ?? false)
return (
<>
<FormControl sx={{ mt: 1, width: '100%' }} size='small'>
<Switch
disabled={disabled}
checked={myValue}
onChange={(event) => {
setMyValue(event.target.checked)
onChange(event.target.checked)
}}
/>
</FormControl>
</>
)
}
SwitchInput.propTypes = {
value: PropTypes.string,
onChange: PropTypes.func,
disabled: PropTypes.bool
}
|