How to create a NavLink using the Button component?

1 Answer 2783 Views
Button
Wreeecks
Top achievements
Rank 2
Iron
Iron
Iron
Wreeecks asked on 27 Sep 2021, 02:02 AM

Hi Guys,

I'm using react-router-dom as my router.

What I wanted to achieve is to make a Button that functions as NavLink. Is there a way to do this? Thanks!

Here's my code:

<Button look="flat">Sign out</Button>

<NavLink to='/signout' look="flat" component={Button}>Sign out</NavLink>

Wreeecks
Top achievements
Rank 2
Iron
Iron
Iron
commented on 27 Sep 2021, 02:07 AM

I think for this case,  i just have to use kendo-ui css 

<NavLink to='/signout' className='k-button k-flat'>Sign out</NavLink>

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 27 Sep 2021, 06:25 AM

Hello, Rex,

This will require using the KendoReact Button as a custom component. I can suggest following the react-router documentation on how to use custom components as links.

The suggested approach with the className is also valid, as our classNames for the button are also applicable for the standard `anchor` elements as well.

Regards,
Stefan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Button
Asked by
Wreeecks
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stefan
Telerik team
Share this question
or