change_color_tab: change_color_tab

Description Usage Details Author(s) Examples

View source: R/change_color_tab.R

Description

change_color_tab changes the color of the text of a tabPanel in a tabSetPanel

Usage

1
change_color_tab(tabId, subTabNumber, color)

Details

This function should be used inside server.R of a shiny app.

Author(s)

Javier Saez Gallego

Examples

 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')
      }
    })
  }
)

jsga/shinyFiddle documentation built on May 20, 2019, 2:08 a.m.