如何移除Quarto仪表盘value box中的展开按钮?
隐藏bslib Value Box的展开按钮
针对你遇到的设置full_screen = FALSE和代码块expandable: false仍无法隐藏展开按钮的问题,可通过以下两种方式解决:
方法1:使用show_full_screen参数(bslib ≥ 0.6.0)
如果你的bslib版本在0.6.0及以上,直接在value_box()函数中添加show_full_screen = FALSE参数即可隐藏展开按钮:
library(palmerpenguins) library(bslib) library(bsicons) # 计算平均喙长 mean_bill_length <- mean(penguins$bill_length_mm, na.rm = TRUE) value_box( title = "平均喙长 (mm)", value = round(mean_bill_length, 1), showcase = bsicons::bs_icon("arrow-right-square"), theme = value_box_theme(bg = "darkviolet", fg = "white"), class = "border", full_screen = FALSE, show_full_screen = FALSE # 隐藏展开按钮 )
方法2:自定义CSS(兼容旧版本bslib)
若你使用的bslib版本较低,无show_full_screen参数,可在Quarto文档中添加自定义CSS来隐藏按钮:
.value-box .full-screen-toggle { display: none !important; }
这段CSS会全局隐藏所有value_box的展开按钮,无需修改R代码。
注意:Quarto代码块的
expandable: false选项对bslib的value_box无效,无需设置该参数。
内容的提问来源于stack exchange,提问作者phaecki
相关产品推荐
相关产品推荐

