Place tab in Shiny tabsetPanel on the right

孤街浪徒 提交于 2019-12-31 02:31:12

问题


By default tabs in a tabsetPanel are put on the left. Is it possible to place a tab on the right side, while still having other tabs on the left? So that it looks like this?

library(shiny)

ui <- fluidPage(
  tabsetPanel(
    tabPanel("tab_left1"),
    tabPanel("tab_left2"),
    tabPanel("tab_right")
  )
)

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

shinyApp(ui, server)

回答1:


Using float-right should indeed work. The problem with using 2 tabsetPanel is that there are 2 active tabs at the same time.

library(shiny)

ui <- fluidPage(
  tags$head(
    tags$style(HTML(
      ".tabbable ul li:nth-child(3) { float: right; }"
    ))
  ),
  tabsetPanel(
    tabPanel("tab_left1"),
    tabPanel("tab_left2"),
    tabPanel("tab_right")
  )
)

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

shinyApp(ui, server)




回答2:


Maybe you can create 2 tabsetPanel and pull one over to the right?

rm(list = ls())
library(shiny)
ui <- fluidPage(
  div(style="display:inline-block",tabsetPanel(type = c("pills"),tabPanel("tab_left1"),tabPanel("tab_left2"))),
  div(style="display:inline-block;float: right",tabsetPanel(type = c("pills"),tabPanel("tab_right")))
)

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

shinyApp(ui, server)




回答3:


When you apply the class float-right to the ones you want to float to the right, it should do the trick.



来源:https://stackoverflow.com/questions/48223155/place-tab-in-shiny-tabsetpanel-on-the-right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!