【问题标题】:How to Change the Font Used in htmlwidgets for R?如何更改 R 的 htmlwidgets 中使用的字体?
【发布时间】:2020-08-21 04:09:51
【问题描述】:

我有一个表,我正在使用 R 中的 reactable 构建一个表,并且想添加一个与我在表本身中使用的字体相同的标题。我想出了如何添加标题,但是如何更改字体?

library(htmlwidgets)
library(reactable)

reactable(head(iris, 10),
          style = list(fontFamily = 'Menlo',
                       fontSize = '14px'),
          highlight = TRUE) %>%
  htmlwidgets::prependContent(htmltools::tags$h1("This is my Title"))

【问题讨论】:

    标签: r


    【解决方案1】:

    您可以在添加标签时设置样式。右键单击列标题显示他们正在使用font-family: Menlo(你要求fontFamily = 'Menlo'的结果),所以这会给你相同的字体:

    reactable(head(iris, 10),
           style = list(fontFamily = 'Menlo',
                        fontSize = '14px'),
           highlight = TRUE) %>%
    htmlwidgets::prependContent(htmltools::tags$h1("This is my Title", 
                                                   style = "font-family: Menlo"))
    

    您也可以使用style = "font-family: Menlo; font-size: 14px" 来匹配大小。

    【讨论】:

      猜你喜欢
      • 2017-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-05
      • 2013-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多