Description Usage Details Author(s) Examples
View source: R/change_color_tab.R
change_color_tab
changes the color of the text of a tabPanel in a tabSetPanel
1 | change_color_tab(tabId, subTabNumber, color)
|
This function should be used inside server.R
of a shiny app.
Javier Saez Gallego
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | require(shiny)
require(shinyjs)
require(devtools)
require(shinyColors)
shinyApp(
ui = fluidPage(
useShinyjs(),
mainPanel(
h4('The colors of the tabs react to the numeric inputs.'),
tabsetPanel(
id = "tabSetId",
tabPanel(
"Input must be positive",
numericInput('numPos', label = "This number should be > 0", value = -1)
)
)
)),
server = function(input, output) {
observeEvent(input$numPos, {
# Change the color of the tab when numPos is negative
if (input$numPos <= 0) {
change_color_tab("tabSetId", 1, 'red')
} else{
change_color_tab("tabSetId", 1, 'black')
}
})
}
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.