Onclick handler on nav link

Can I use onclick={handlerLogIn} on nav link without using a button? <Nav.Link style={{backgroundColor: “#ff6e40”}} href="#link">Login</Nav.Link>

Are you using React-Bootstrap?

Not sure what you mean by “without using a button”. Nav.Link just renders an anchor element.

You can pretty much put onClick handlers on everything (doesn’t mean that you should, just that you can).

1 Like

yes,I am using react bootstrap.I want to use onClick in order to create show my login form.Sorry for my bad English.

As I said, you can add onClick handlers to anything.

Did you try? Does your code not work? If so it’s likely not related to the element it is attached to.