The shinyFeedback
package allows for the insertion of conditional feedback messages along side shiny
inputs.
In order to use shinyFeedback
you need to include the following two functions at the top of your UI.
useShinyFeedback()
The following is a minimal example of a shiny
app that uses shinyFeedback
. Run the following code in your R console to run the app.
library(shiny)
library(shinyFeedback)
ui <- fluidPage(
useShinyFeedback(), # include shinyFeedback
numericInput(
"warningInput",
"Warn if Negative",
value = -5
)
)
server <- function(input, output) {
observeEvent(input$warningInput, {
feedbackWarning(
inputId = "warningInput",
condition = input$warningInput < 0
)
})
}
shinyApp(ui, server)
feedback
functionThe primary function provided by shinyFeedback
is feedback
. feedback
allows you to set the color of the feedback, the icon to be displayed in the right corner of the input box, and the text that appears beneath the input. The feedback is displayed when the expression supplied to the condition
argument evaluates to TRUE. Run ?feedback
in your R console for more information.
feedback
wrappersshinyFeedback
has 3 convenient wrappers functions: - feedbackWarning
- feedbackDanger
- feedbackSuccess
These functions provide default arguments for all the formal arguments in the feedback
function other than inputId
and condition
. A live app using these function is available here.