MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / SwitchInput

Function SwitchInput

packages/ui/src/ui-component/switch/Switch.jsx:5–30  ·  view source on GitHub ↗
({ label, value, onChange, disabled = false })

Source from the content-addressed store, hash-verified

3import { FormControl, Switch, Typography } from '@mui/material'
4
5export const SwitchInput = ({ label, value, onChange, disabled = false }) => {
6 const [myValue, setMyValue] = useState(value !== undefined ? !!value : false)
7
8 useEffect(() => {
9 setMyValue(value !== undefined ? !!value : false)
10 }, [value])
11
12 return (
13 <>
14 <FormControl
15 sx={{ mt: 1, width: '100%', display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}
16 size='small'
17 >
18 {label && <Typography>{label}</Typography>}
19 <Switch
20 disabled={disabled}
21 checked={myValue}
22 onChange={(event) => {
23 setMyValue(event.target.checked)
24 onChange(event.target.checked)
25 }}
26 />
27 </FormControl>
28 </>
29 )
30}
31
32SwitchInput.propTypes = {
33 label: PropTypes.string,

Callers

nothing calls this directly

Calls 1

onChangeFunction · 0.50

Tested by

no test coverage detected