The onclick method is simple, but it relies on javascript. More importantly, it will be inconvenient if you want to dynamically generate a link. I want my application to have a link that opens a specific page according to user input, and I find that you can simply style the link as a button.
First, I consider the dynamic part with uiOutput and renderUI , because the link can only be created in the server part. Simple link will be
a(h4("Open Link"), target = "_blank", href = paste0("http://www.somesite/", some_link))
Just run this line in R, we get
<a target="_blank" href="http://www.somesite/somelink"> <h4>Open Link</h4> </a>
To create a button, we can see what the action button looks like.
> actionButton("download", "Download Selected", icon = icon("cloud-download")) <button id="download" type="button" class="btn btn-default action-button"> <i class="fa fa-cloud-download"></i> Download Selected </button>
Then we can do it
shiny::a(h4("Open Link", class = "btn btn-default action-button" , style = "fontweight:600"), target = "_blank", href = paste0("http://www.somesite/", some_link))
To obtain
<a target="_blank" href="http://www.somesite/some_link"> <h4 class="btn btn-default action-button" style="fontweight:600">Open Link</h4> </a>
Now we have a link that looks like a button, and you can further customize its style either with a style parameter or with CSS. Open the application using the chrome / firefox developer tools, change the css to the effect you want, and then add the changed css in style.css to the www folder to override the default style.
If you look at the output of many html tag functions, you will find that you can actually combine and assemble a lot of materials to get a lot of customization.