【发布时间】:2020-02-15 15:24:12
【问题描述】:
我想将verbatimTextOutput 的字体系列更改为与Shiny 和Shinydashboard 中的输入相同。这是一个例子。
# Load the packages
library(shiny)
library(shinydashboard)
# User Interface
ui <- dashboardPage(
header = dashboardHeader(title = ""),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem(
text = "Example",
tabName = "tab1"
)
)
),
body = dashboardBody(
tabItems(
tabItem(
tabName = "tab1",
fluidRow(
column(
width = 4,
numericInput(inputId = "Number", label = "A numeric input", value = NA),
strong("The same number as the numeric input"),
verbatimTextOutput("Number_out")
)
)
)
)
)
)
server <- function(input, output, session){
output$Number_out <- renderText(as.character(input$Number))
}
# Run the app
shinyApp(ui, server)
通过运行应用程序并输入一个数字,我们可以看到numericInput 和verbatimTextOutput 中的字体系列是不同的。
根据这个答案 (https://stackoverflow.com/a/48037443/7669809) 和这个答案 (https://stackoverflow.com/a/50784117/7669809),我编辑了我的脚本如下。
# Load the packages
library(shiny)
library(shinydashboard)
# User Interface
ui <- dashboardPage(
header = dashboardHeader(title = ""),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem(
text = "Example",
tabName = "tab1"
)
)
),
body = dashboardBody(
tags$head(
tags$style(
HTML(
'#Number_out {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 12px;
}'
)
)
),
tabItems(
tabItem(
tabName = "tab1",
fluidRow(
column(
width = 4,
numericInput(inputId = "Number", label = "A numeric input", value = NA),
strong("The same number as the numeric input"),
verbatimTextOutput("Number_out")
)
)
)
)
)
)
server <- function(input, output, session){
output$Number_out <- renderText(as.character(input$Number))
}
# Run the app
shinyApp(ui, server)
但字体系列还是不一样。
看来我还没有使用正确的字体系列。请告诉我如何实现这一目标。
【问题讨论】:
标签: html css r shiny shinydashboard