如何修改 shinythemes 的主题?
How to modify the themes of shinythemes?
如何修改shinythemes
的主题?例如,假设我想将 darkly
的背景更改为黑色。
library(shiny)
library(shinythemes)
ui <- fluidPage(
theme = shinytheme("darkly"),
"How to change this black?")
server <- function(input, output) {}
shinyApp(ui, server)
我想一个解决方案是将 darkly
的 CSS 和修改后的黑色复制到我的应用程序的 www 文件夹中,然后使用 theme = "darkly_modified_black.css"
。我缺少更简单的解决方案吗?
如果您只想更改背景颜色,您可以包含自己的 css 参数。
但是,是的,你也可以复制 darkly 的 css,修改它,将它包含在 www 文件夹中并从那里加载它。
library(shiny)
library(shinythemes)
css <- HTML(" body {
background-color: #000000;
}")
ui <- fluidPage(
tags$head(tags$style(css)),
theme = shinytheme("darkly"),
"How to change this black?")
server <- function(input, output) {}
shinyApp(ui, server)
如果您想要一个单独的 .css 文件,您可以使用 includeCSS
和文件路径。
我知道这是一个很老的问题,但我刚刚找到了另一种方法。 fresh
包也很有用。事实上,有人发布了如何使用 NavbarPage
更改 shinythemes 的基调,而我只有 answered.
这是我的解决方案:
library(shiny)
library(shinythemes)
library(fresh)
ui <- fluidPage(
use_theme(create_theme(
theme = "default",
bs_vars_global(
body_bg = "#000",
text_color = "#FFF"
))),
theme = shinytheme("darkly"),
"How to change this black?")
server <- function(input, output) {}
shinyApp(ui, server)
您可以创建主题以用于:
- Shiny 本身,带有 shiny::fluidPage 或 shiny::navbarPage 或来自 Bootswatch 的主题 (https://dreamrs.github.io/fresh/articles/vars-shiny.html)
- 闪亮仪表板(https://dreamrs.github.io/fresh/articles/vars-shinydashboard.html)
- bs4Dash (https://dreamrs.github.io/fresh/articles/vars-bs4dash.html)
这里有更多关于包裹的info。
如何修改shinythemes
的主题?例如,假设我想将 darkly
的背景更改为黑色。
library(shiny)
library(shinythemes)
ui <- fluidPage(
theme = shinytheme("darkly"),
"How to change this black?")
server <- function(input, output) {}
shinyApp(ui, server)
我想一个解决方案是将 darkly
的 CSS 和修改后的黑色复制到我的应用程序的 www 文件夹中,然后使用 theme = "darkly_modified_black.css"
。我缺少更简单的解决方案吗?
如果您只想更改背景颜色,您可以包含自己的 css 参数。 但是,是的,你也可以复制 darkly 的 css,修改它,将它包含在 www 文件夹中并从那里加载它。
library(shiny)
library(shinythemes)
css <- HTML(" body {
background-color: #000000;
}")
ui <- fluidPage(
tags$head(tags$style(css)),
theme = shinytheme("darkly"),
"How to change this black?")
server <- function(input, output) {}
shinyApp(ui, server)
如果您想要一个单独的 .css 文件,您可以使用 includeCSS
和文件路径。
我知道这是一个很老的问题,但我刚刚找到了另一种方法。 fresh
包也很有用。事实上,有人发布了如何使用 NavbarPage
更改 shinythemes 的基调,而我只有 answered.
这是我的解决方案:
library(shiny)
library(shinythemes)
library(fresh)
ui <- fluidPage(
use_theme(create_theme(
theme = "default",
bs_vars_global(
body_bg = "#000",
text_color = "#FFF"
))),
theme = shinytheme("darkly"),
"How to change this black?")
server <- function(input, output) {}
shinyApp(ui, server)
您可以创建主题以用于:
- Shiny 本身,带有 shiny::fluidPage 或 shiny::navbarPage 或来自 Bootswatch 的主题 (https://dreamrs.github.io/fresh/articles/vars-shiny.html)
- 闪亮仪表板(https://dreamrs.github.io/fresh/articles/vars-shinydashboard.html)
- bs4Dash (https://dreamrs.github.io/fresh/articles/vars-bs4dash.html)
这里有更多关于包裹的info。