skip to Main Content

Problem:

I’m working on a Shiny app using the bs4Dash package, and I have a tabCard containing nested tabsetPanels. However, there is a small tab at the top of the ‘tabCard’ that I’d like to remove, as it provides unwanted functionality and is a visual distraction. I’ve tried looking for options within the bs4TabCard function, but I haven’t found a solution yet. I would like the tabs and sub-tabs to be displayed in a ‘bs4Dash::tabBox’ or ‘bs4Dash::tabCard’.

Reprex:

ui <- bs4Dash::bs4DashPage(
    header = bs4Dash::bs4DashNavbar(),
    sidebar = bs4Dash::bs4DashSidebar(disable = TRUE),
    body = bs4Dash::bs4DashBody(
        fluidPage(
            bs4Dash::bs4TabCard(
                width = 12,
                collapsible = FALSE,
                tabsetPanel(
                    id = "main_tabs",
                    tabPanel("Price",
                             tabsetPanel(
                                 id = "price_tabs",
                                 tabPanel("Mandelbrot", "Content for Mandelbrot"),
                                 tabPanel("Momentum", "Content for Momentum"),
                                 tabPanel("Past Returns", "Content for Past Returns")
                             )
                    ),
                    tabPanel("Volume",
                             tabsetPanel(
                                 id = "volume_tabs",
                                 tabPanel("Momentum", "Content for Momentum"),
                                 tabPanel("Historical", "Content for Historical")
                             )
                    ),
                    tabPanel("Volatility",
                             tabsetPanel(
                                 id = "volatility_tabs",
                                 tabPanel("Momentum", "Content for Momentum"),
                                 tabPanel("IVOL/RVOL", "Content for IVOL/RVOL"),
                                 tabPanel("Gross/Degross", "Content for Gross/Degross")
                             )
                    ),
                    tabPanel("Positioning",
                             tabsetPanel(
                                 id = "positioning_tabs",
                                 tabPanel("Put/Call/Ratio", "Content for Put/Call/Ratio"),
                                 tabPanel("Short Interest", "Content for Short Interest"),
                                 tabPanel("Number of Shares", "Content for Number of Shares")
                             )
                    )
                )
            )
        )
    ),
    controlbar = NULL,
    footer = NULL
)


server <- function(input, output, session) {
}


shinyApp(ui, server)

I have tried to move around and change different bs4Dash components or shiny components but I can’t seem to find the right combination. There is a possible solution by hiding the header with some CSS, but I would prefer to not go about it this way, as it seems possible to do with the correct layout of components.

Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    This is the current implementation of solving this, but I would like to reduce all CSS styling if I can to simplify and speed up the code.

    ui3 <- bs4Dash::bs4DashPage(
        header = bs4Dash::bs4DashNavbar(),
        sidebar = bs4Dash::bs4DashSidebar(disable = TRUE),
        body = bs4Dash::bs4DashBody(
            fluidPage(
                tags$head(
                    tags$style(
                        ".card-header.p-0.border-bottom-0 { display: none; }"
                    )
                ),
                bs4Dash::bs4TabCard(
                    width = 12,
                    collapsible = FALSE,
                    tabsetPanel(
                        id = "main_tabs",
                        tabPanel("Price",
                                 tabsetPanel(
                                     id = "price_tabs",
                                     tabPanel("Mandelbrot", "Content for Mandelbrot"),
                                     tabPanel("Momentum", "Content for Momentum"),
                                     tabPanel("Past Returns", "Content for Past Returns")
                                 )
                        ),
                        tabPanel("Volume",
                                 tabsetPanel(
                                     id = "volume_tabs",
                                     tabPanel("Momentum", "Content for Momentum"),
                                     tabPanel("Historical", "Content for Historical")
                                 )
                        ),
                        tabPanel("Volatility",
                                 tabsetPanel(
                                     id = "volatility_tabs",
                                     tabPanel("Momentum", "Content for Momentum"),
                                     tabPanel("IVOL/RVOL", "Content for IVOL/RVOL"),
                                     tabPanel("Gross/Degross", "Content for Gross/Degross")
                                 )
                        ),
                        tabPanel("Positioning",
                                 tabsetPanel(
                                     id = "positioning_tabs",
                                     tabPanel("Put/Call/Ratio", "Content for Put/Call/Ratio"),
                                     tabPanel("Short Interest", "Content for Short Interest"),
                                     tabPanel("Number of Shares", "Content for Number of Shares")
                                 )
                        )
                    )
                )
            )
        ),
        controlbar = NULL,
        footer = NULL
    )
    
    
    server <- function(input, output, session) {
    }
    
    
    shinyApp(ui, server)
    

  2. Use bs4Card() instead of bs4TabCard():

    bs4Dash::bs4Card(
      width = 12,
      collapsible = FALSE,
      headerBorder = FALSE,
      ...
    )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search