簡體   English   中英

設置主題由 bslib 定義時的 R shiny 模態寬度

[英]Set R shiny modal width when theme is defined by bslib

當 bs_theme() 處於活動狀態時,如何將模態寬度設置為 80%? bs_theme() 中是否有可能? 我只是無法正確使用標簽。

library(shiny)
library(bslib)
ui <- fluidPage(
    shiny::bootstrapLib(),
    theme = bs_theme(
        version = 4,
        bootswatch = "minty"),
    tags$style(".modal-dialog{width: 80% !important;}"),
    actionButton("open_modal", "open modal"),
)

server <- function(input, output) {
    observeEvent(input$open_modal, {
        showModal(
            modalDialog(
                title = "This modal isn't 80% wide")
        )
    })
} 
shinyApp(ui = ui, server = server)

使用tags$style(".modal-dialog {max-width: 80vw;}")代替。 它確保您的模態始終占整個 window 的 80%,並在您更改 window 大小時自動調整大小。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM