我有一個應用程式,用于box::dropdownMenu呈現用戶將用來設定繪圖選項的下拉選單。我能夠毫無問題地實作此功能,但我想做另外兩件事。
是否可以:(1)隱藏齒輪圖示右側的箭頭?(2) 在下拉選單上,是否可以保持文本左對齊,但單選按鈕右對齊?
當前狀態:

期望的最終結果:

代碼:
library(shiny)
library(shinyWidgets)
library(shinydashboardPlus)
ui <- fluidPage(
box(
title = "Box Title",
dropdownMenu = dropdown(
width = "200px",
icon = icon("gear"),
materialSwitch(inputId = "Id079", label = "Color:"),
materialSwitch(inputId = "Id079", label = "Display Goal:"),
),
textOutput("text")
)
)
server <- function(input, output, session) {
output$text <- renderText("Hello World!")
}
shinyApp(ui, server)
uj5u.com熱心網友回復:
- 要洗掉箭頭,應更改
style為默認值以外的其他內容。例如,您可以使用fill或bordered。
shinyWidgets::dropdown(
width = "200px",
style = "fill",
icon = icon("cog"),
materialSwitch(inputId = "Id079", label = "Color:"),
# Change IDs to unique IDs otherwise it won't work
materialSwitch(inputId = "Id080", label = "Display Goal:"),
)
- 對于對齊,您可以使用
.label-default元素(屬性?)
ui <- fluidPage(
# Need to play with the margin-left part
tags$head(tags$style(HTML(".label-default{
margin-left: 50px;}
"))),
shinyWidgets::dropdown(
width = "300px",
style = "fill",
icon = icon("cog"),
materialSwitch(inputId = "Id079", label = "Color:"),
materialSwitch(inputId = "Id080", label = "Display Goal:"),
),
textOutput("text")
)
這樣做的問題是要統一更改不相等標簽的邊距并不容易。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/390430.html
上一篇:如何在R中將事件資料重組為二元
