Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny How make a help box appear with an action button

Tags:

r

button

shiny

I have created an action button as follows in my ui

div(style="display:inline-block",actionButton("action", label = "Help"))

I want this button to create a help box which the user can close which contains text on how to use this app. How do i do this?

Also, how do I customise this button? such as font, colour, alignment...

Thanks

like image 793
vik Avatar asked Mar 01 '15 21:03

vik


People also ask

How do you use the shiny action button?

Create an action button with actionButton() and an action link with actionLink() . Each of these functions takes two arguments: inputId - the ID of the button or link. label - the label to display in the button or link.

What are Shiny widgets?

Shiny widgets enable you to create re-usable Shiny components that are included within an R Markdown document using a single function call. Shiny widgets can also be invoked directly from the console (useful during authoring) and show their output within the RStudio Viewer pane or an external web browser.

Which function is used to create the shiny app?

shinyApp. Finally, we use the shinyApp function to create a Shiny app object from the UI/server pair that we defined above. We save all of this code, the ui object, the server function, and the call to the shinyApp function, in an R script called app.


1 Answers

Clicking the action button increments a value, initially 0. You could use renderUI in your server.R file to define a widget that is empty when input$action is even, and helpText when it is odd. That way, the same action button would both open and close the help.

output$HelpBox = renderUI({
  if (input$action %% 2){
    helpText("Here is some help for you")
  } else {
    return()
  }
})

In ui.R, use the uiOutput function to display the widget. Remember that it will display nothing until the action button is clicked.

uiOutput("HelpBox")
like image 171
Paul de Barros Avatar answered Oct 11 '22 16:10

Paul de Barros