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

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

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")

Related

Refreshing R Shiny Result Panel without closing app

I am updating one of my Shiny apps and have implemented a "Refresh" button that is supposed to remove output from the Result Panel (i.e., where plots/tables are printed to) in Shiny:
actionBttn(inputId = "refresh",
label = "Refresh",
color = "success",
style = "jelly",
size ="sm",
block = FALSE
)
I have seen this previous SO Post: refresh the main panel screen in shiny using the action button, which is not exactly what I'm after, since running it simply closes the app itself (which can be accomplished directly in RStudio anyway). I swapped an observe() for an observeEvent(). Trying it both ways gave the same behaviour.
In my case, the app window should remain open, but upon pressing the "Refresh" button, should result in a blank Result Panel.

Shiny - display image next to widget for info pop-up

I'm trying to display an information (i) image next to a selectInput control in Shiny, which the user can click on to display some more extensive help about the control.
I can use renderImage to display the image and modalDialog combined with a click event on the rendered image to display the information. HOWEVER what I am unable to achieve is to put the image next to the widget. By default it displays below the widget. Theoretically I could put the image in a new column but this leads to far too much space between the widget and the image.
Is there any way around this? Alternatively, can I display the image in the control's label while still allowing it to be clicked?
You could use the property display:inline-block the elements that should appear next to each other. Working example:
library(shiny)
ui <- fluidPage(
div(style='display: inline-block;',
selectInput('input','Input: ', choices=LETTERS[1:10])
),
img(src='https://www.zorro.com/wp-content/uploads/cc_resize/005-1200x542.jpg',height='100px',style='display: inline-block;'))
server <- function(input, output, session) {
}
shinyApp(ui, server)
Furthermore, you can use e.g. margin-left:100px in the image style to control the space between the elements.
Hope this helps!

jssor - Go to next slide when clicking a "next" button or selecting a radio button

I am using the jssor Tab Slider to create an animated form. I want to add the option to move to the next slide within the content (not just by clicking the tabs at the top...)
2 ways I want to move to the next slide:
1. Select a radio button
2. Click continue button
I've tried adding data-u="arrowright" to my continue button, and it completely erased my tab navigation. I'm still not sure how to even start with the radio buttons.
I'm a newbie and need help!
Thanks
var jssor_slider1 = new $JssorSlider$(...;
$('img.next').click(function () {
jssor_slider1.$Next();
});
Hope this help.
jssor_slider1.$GoTo( myImageNum )

Send selectInput value when input changed (without needing submit button) Shiny R

I am trying to make it so that when I change my selectInput value it reactive value is passed automatically without needing to press a submit button. Is this possible?
selectInput("variable1", "Choose ID:", vec)
The above requires a submit button to be clicked before the value is passed.

R: submitButton and conditionalPanel

I've got a UI that is entirely build with conditional panels. But the problem I am having now is that I need a submit button. When introducing the submit button, it will render all the conditional UI to not show up conditionally unless I press the submit button.
My question is if there is a way so that the conditional display of various UI sliders, input, etc be not dependent on the submit button?
Thanks,
I had this problem when I was using the submit button to crunch data intensive code that was dependent on the widgets I programmed on the reactive interface. As soon as I added a submit button, all reactive widgets became static until i pressed the submit button (which was a pain because I had a reactive plot on the main panel). Thanks to the wonderful Mr. Cheng, I found out that you cannot (yet) make individual widgets dependent on a submit button. It is an all or nothing kind of deal. Therefore it may better to use an 'actionButton', sandwiched between the 'observe' and 'isolate' functions. It may look something like this..
observe({
if (input$action_button == 0) # tells action button to do nothing when not clicked ..
return()
isolate({ # this isolates the code you want to execute when clicking the action button..
###some function or conditional panel###
})})
Hopefully this works for you. It did for me :)

Resources