Answers for "import switch material ui"

1

material-ui switch

import React from "react";
import Switch from "@material-ui/core/Switch";

export default function MaterialuiSwitch() {

  const [state, setState] = React.useState(false);

  function handleSwitchChange (e) {
    setState(e.target.checked);
    // Add actions here for when the switch is triggered
  };

  var text;

  if (state) {
    text = 'on';
  } else {
    text = 'off';
  };

  return (
    <div>
      {text}
      <Switch
        checked={state}
        onChange={handleSwitchChange}
        color="primary"
      />
    </div>
  );
};
Posted by: Guest on February-19-2021
1

import switch material ui

import Switch from '@material-ui/core/Switch';
Posted by: Guest on February-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language