[Solved] Defining a custom text function in R Shiny

DJC Asks: Defining a custom text function in R Shiny
I have a very simply shiny app that just renders some text:

Code:
library(magrittr)
library(shiny)

ui <- fluidPage(
  h5("This is some text")
)

server <- function(input, output, session) {
}

shinyApp(ui, server)

I would like to change the styling of this text, for example, to make the text color red. I know that I can do this by creating a ‘www’ subfolder and adding some css in a file called ‘custom’:

Code:
.h5, h5 {
    color: #FF0000;
}

And then reference this stylesheet in the app:

Code:
ui <- fluidPage(
  tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")),
  h5("This is some text")
)

server <- function(input, output, session) {
}

shinyApp(ui, server)

Doing this accomplishes what I want, but it overwrites the properties for the h5 function. Is there anyway to create a duplicate h5 function (maybe h5_red) and apply the css to that, so that I can retain the default properties of h5, but also use my new h5_red function throughout my app as needed?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.