Title: | Display User Feedback in Shiny Apps |
---|---|
Description: | Easily display user feedback in Shiny apps. |
Authors: | Andy Merlino [aut, cre], Patrick Howard [aut] |
Maintainer: | Andy Merlino <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0.9001 |
Built: | 2024-11-22 03:21:15 UTC |
Source: | https://github.com/merlinoa/shinyfeedback |
Show / hide feedback messages.
feedback( inputId, show, text = NULL, color = NULL, icon = NULL, textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) feedbackWarning( inputId, show, text = "Ye be warned", color = "#F89406", icon = shiny::icon("warning-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) feedbackDanger( inputId, show, text = "Danger, turn back!", color = "#d9534f", icon = shiny::icon("exclamation-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) feedbackSuccess( inputId, show, text = NULL, color = "#5cb85c", icon = shiny::icon("ok", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() )
feedback( inputId, show, text = NULL, color = NULL, icon = NULL, textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) feedbackWarning( inputId, show, text = "Ye be warned", color = "#F89406", icon = shiny::icon("warning-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) feedbackDanger( inputId, show, text = "Danger, turn back!", color = "#d9534f", icon = shiny::icon("exclamation-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) feedbackSuccess( inputId, show, text = NULL, color = "#5cb85c", icon = shiny::icon("ok", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() )
inputId |
the Shiny input's |
show |
Whether or not the feedback should be shown. The 'show' argument uses 'shiny::isTruthy()' to evaluate its value to 'TRUE' or 'FALSE'. |
text |
text string to display below input |
color |
the color of the feedback |
icon |
an html icon tag |
textPosition |
the CSS position for the div containing the feedback text. The default is "relative". Set to "absolute" to keep the text from shifting other elements on the page. |
session |
the |
showFeedback hideFeedback
hide feedback next to Shiny input
hideFeedback(inputId, session = shiny::getDefaultReactiveDomain())
hideFeedback(inputId, session = shiny::getDefaultReactiveDomain())
inputId |
the Shiny input's |
session |
the |
Hide existing toast messages
hideToast(animate = TRUE, session = shiny::getDefaultReactiveDomain())
hideToast(animate = TRUE, session = shiny::getDefaultReactiveDomain())
animate |
a logical indicating whether to remove the toast message(s) instantly or use its |
session |
the Shiny session. Defaults to |
'invisible()'
Button that becomes disabled until reset w/ 'resetLoadingButton'
loadingButton( inputId, label, class = "btn btn-primary", style = "width: 150px;", loadingLabel = "Loading...", loadingSpinner = "spinner", loadingClass = NULL, loadingStyle = NULL )
loadingButton( inputId, label, class = "btn btn-primary", style = "width: 150px;", loadingLabel = "Loading...", loadingSpinner = "spinner", loadingClass = NULL, loadingStyle = NULL )
inputId |
the input id |
label |
the button text (label) |
class |
the class(es) to apply to the button |
style |
style for button (pre-loading); character string w/ CSS styling format: "color: black; background-color: red;" |
loadingLabel |
text to show after button is clicked (e.g. during loading) |
loadingSpinner |
the loading spinner icon. Valid values are NULL, "spinner", "circle-notch", "sync", and "cog" |
loadingClass |
the loading button css class(es). |
loadingStyle |
style for button (while loading); character string w/ CSS styling format: "color: black; background-color: red;" |
Reset the 'loadingButton' to its original style
resetLoadingButton(inputId, session = shiny::getDefaultReactiveDomain())
resetLoadingButton(inputId, session = shiny::getDefaultReactiveDomain())
inputId |
the input id |
session |
the shiny session |
Show feedback next to Shiny inputs.
showFeedback( inputId, text = NULL, color = NULL, icon = NULL, textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) showFeedbackWarning( inputId, text = "Ye be warned", color = "#F89406", icon = shiny::icon("warning-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) showFeedbackDanger( inputId, text = "Danger, turn back!", color = "#d9534f", icon = shiny::icon("exclamation-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) showFeedbackSuccess( inputId, text = NULL, color = "#5cb85c", icon = shiny::icon("ok", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() )
showFeedback( inputId, text = NULL, color = NULL, icon = NULL, textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) showFeedbackWarning( inputId, text = "Ye be warned", color = "#F89406", icon = shiny::icon("warning-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) showFeedbackDanger( inputId, text = "Danger, turn back!", color = "#d9534f", icon = shiny::icon("exclamation-sign", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() ) showFeedbackSuccess( inputId, text = NULL, color = "#5cb85c", icon = shiny::icon("ok", lib = "glyphicon"), textPosition = "relative", session = shiny::getDefaultReactiveDomain() )
inputId |
the Shiny input's |
text |
text string to display below input |
color |
the color of the feedback |
icon |
an html icon tag |
textPosition |
the CSS position for the div containing the feedback text. The default is "relative". Set to "absolute" to keep the text from shifting other elements on the page. |
session |
the |
## Only run examples in interacive R sessions if (interactive()) { ui <- fluidPage( useShinyFeedback(), numericInput( "exampleInput", "Show Feedback When < 0", value = -5 ) ) server <- function(input, output) { observeEvent(input$exampleInput, { if (input$exampleInput < 0) { showFeedback( "exampleInput", text = "I am negative", color = "#d9534f", icon = shiny::icon("exclamation-sign", lib="glyphicon") ) } else { hideFeedback("exampleInput") } }) } shinyApp(ui, server) } ## Only run examples in interacive R sessions if (interactive()) { library(shiny) ui <- fluidPage( useShinyFeedback(), numericInput( "exampleInput", "Show Feedback When < 0", value = -5 ) ) server <- function(input, output, session) { observeEvent(input$exampleInput, { if (input$exampleInput < 0) { showFeedbackWarning("exampleInput") } else { hideFeedback("exampleInput") } }) } shinyApp(ui, server) }
## Only run examples in interacive R sessions if (interactive()) { ui <- fluidPage( useShinyFeedback(), numericInput( "exampleInput", "Show Feedback When < 0", value = -5 ) ) server <- function(input, output) { observeEvent(input$exampleInput, { if (input$exampleInput < 0) { showFeedback( "exampleInput", text = "I am negative", color = "#d9534f", icon = shiny::icon("exclamation-sign", lib="glyphicon") ) } else { hideFeedback("exampleInput") } }) } shinyApp(ui, server) } ## Only run examples in interacive R sessions if (interactive()) { library(shiny) ui <- fluidPage( useShinyFeedback(), numericInput( "exampleInput", "Show Feedback When < 0", value = -5 ) ) server <- function(input, output, session) { observeEvent(input$exampleInput, { if (input$exampleInput < 0) { showFeedbackWarning("exampleInput") } else { hideFeedback("exampleInput") } }) } shinyApp(ui, server) }
A wrapper around the 'toastr' JavaScript library that uses our preferred default argument values.
showToast( type, message, title = NULL, keepVisible = FALSE, .options = list(), session = shiny::getDefaultReactiveDomain() )
showToast( type, message, title = NULL, keepVisible = FALSE, .options = list(), session = shiny::getDefaultReactiveDomain() )
type |
length 1 character vector. Valid values are "success", "error", "warning", and "info" |
message |
the toast message |
title |
the toast title. Defaults to |
keepVisible |
a logical. If |
.options |
other options to pass to the |
session |
the Shiny session. Defaults to |
'invisible()'
function to load js for using shinyFeedback
useShinyFeedback(feedback = TRUE, toastr = TRUE)
useShinyFeedback(feedback = TRUE, toastr = TRUE)
feedback |
boolean: source in JS/CSS to use shinyFeedback functions (Default: |
toastr |
boolean: source in JS/CSS to use showToast functions (Default: |
ui <- shinyUI(fluidPage( useShinyFeedback( feedback = TRUE, toastr = TRUE ), pageWithSidebar( headerPanel("Header"), sidebarPanel( ... ), mainPanel( ... ) ) ))
Server function for the 'valueBoxModule'. 'valueBoxModule' is similar to 'shinydashboard::valueBox()' but it moves the UI from the server to the ui ( i.e. the entire box is not rendered when the value in the value box updates; only the actual value is rerendered). By moving the box content to the UI the value box does not flash onto the screen when rendered.
valueBoxModule(input, output, session, value, subtitle = function() NULL)
valueBoxModule(input, output, session, value, subtitle = function() NULL)
input |
the Shiny server input |
output |
the Shiny server output |
session |
the Shiny server session |
value |
Either a reactive or an R object that can be coerced into a string. The value to be displayed in the value box. |
subtitle |
reactive to dynamically set the subtitle. Set the "subtitle" argument
of |
'valueBoxModule' also allows for more custom styling of the box colors than 'shinydashboard::valueBox()'.
valueBoxModuleUI
valueBoxModuleUI( id, subtitle, icon = NULL, backgroundColor = "#7cb5ec", textColor = "#FFF", width = 4, href = NULL, iconColor = "#00000026" )
valueBoxModuleUI( id, subtitle, icon = NULL, backgroundColor = "#7cb5ec", textColor = "#FFF", width = 4, href = NULL, iconColor = "#00000026" )
id |
the Shiny module id |
subtitle |
The subtitle to be displayed in the value box. Set to "__server__" to dynamically render the subtitle from the server. |
icon |
An icon made by the 'shiny::icon()' |
backgroundColor |
A hex color code string |
textColor |
A hex color code string |
width |
A number between 1 and 12 |
href |
A url |
iconColor |
A valid color string |