Categories
React Answers

How to make a React Material UI Raised Button link to an external URL?

Spread the love

To make a React Material UI Raised Button link to an external URL, we can add a Button that has the variant prop set to contained.

Then we set the href prop of the button to the URL we want to go to.

For instance, we write:

import React from "react";
import Button from "@material-ui/core/Button";
export default function App() {
  return (
    <div>
      <Button variant="contained" href="https://example.com">
        Yahoo
      </Button>
    </div>
  );
}

to add a Button with the variant prop set to 'contained' to add a raised button.

And we set the href prop to 'https://example.com' to make the button go to https://example.com when we click it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *