How to Add OnClick Function to Material-UI Button in React

As you know, material-ui is one of the most popular react component library which implements Google’s material design. When you are looking the props for Button in material-ui you may notice that onClick is missing.

Yes, you are right, material-ui has not documented common react events. You can add onClick function to material-ui Button as given below:

              <Button
                variant="contained"
                color="primary"
                onClick={() => {
                  console.log('clicked');
                }}
              >
               
              </Button>

Similar Posts

Leave a Reply