# NOT RUN {
## 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)
}
# }
Run the code above in your browser using DataLab