Easiest way to change the whole font in shiny app in R?

Viewed 563

I would like to know how to change the whole Font Family in my shiny app. Is it possible to past anything before my whole code? Is there a template?

Do I need to implement something in Ui and Server?

Thank you :)

2 Answers

You can add something like this into ui component;

tags$head(tags$style('body {font-family: Arial;}'))

Add more options into the quote to customise further;

tags$head(tags$style('
   body {
      font-family: Arial; 
      font-size: 20px; 
      font-style: italic;
   }'
))

you can find lots of shiny themes in here

library(shiny)
library(shinythemes)
shinyApp(
  ui = fluidPage(
    shinythemes::themeSelector(),  # <--- Add this somewhere in the UI
    sidebarPanel(
      textInput("txt", "Text input:", "text here"),
      sliderInput("slider", "Slider input:", 1, 100, 30),
      actionButton("action", "Button"),
      actionButton("action2", "Button2", class = "btn-primary")
    ),
    mainPanel(
      tabsetPanel(
        tabPanel("Tab 1"),
        tabPanel("Tab 2")
      )
    )
  ),
  server = function(input, output) {}
)
Related