Add link to a button in React Button component

7 Aug 20232 minutes to read

The appearance of the Button can be changed like a link by e-link class using cssClass property and link navigation can be handled in Button click.

In the following example, link is added in Button click by using window.open() method.

import { enableRipple } from '@syncfusion/ej2-base';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
    // Click Event.
    function btnClick() {
        window.open("https://www.google.com");
    }
    return (<div>
            <ButtonComponent cssClass='e-link' onClick={btnClick}>Go to google</ButtonComponent>
        </div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('button'));
import { enableRipple } from '@syncfusion/ej2-base';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';

enableRipple(true);

function App() {
    // Click Event.
    function btnClick (): void {
      window.open("https://www.google.com");
    }
    return (
        <div>
            <ButtonComponent cssClass='e-link' onClick={btnClick}>Go to google</ButtonComponent>
        </div>
    );
}
export default App;
ReactDom.render(<App />,document.getElementById('button'));