Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny - change color of text in navbarPage

Tags:

r

shiny

I achieve to change the background color of the navbar using css style but not the color of the text... I reproduce a basic example below to my code.

ui <- function(){

  bootstrapPage('',

      navbarPage(title = 'Hello'),

      tags$style(type = 'text/css', '.navbar { background-color: #262626;
                                               font-family: Arial;
                                               font-size: 13px;
                                               color: #FF0000; }',

                                '.navbar-dropdown { background-color: #262626;
                                                    font-family: Arial;
                                                    font-size: 13px;
                                                    color: #FF0000; }'))

}

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


shinyApp(ui = ui, server = server)
like image 612
marnau901e Avatar asked Apr 14 '17 22:04

marnau901e


People also ask

How to theme a shiny app in R?

To theme a Shiny app, also check out the bslib package. From the docs: " The bslib R package provides tools for customizing Bootstrap themes directly from R, making it much easier to customize the appearance of Shiny apps & R Markdown documents." Thank you so much @williaml !

What does the navigation bar value mean in tabpanel?

The value will correspond to the value argument that is passed to tabPanel. Determines whether the navbar should be displayed at the top of the page with normal scrolling behavior ( "static-top" ), pinned at the top ( "fixed-top" ), or pinned at the bottom ( "fixed-bottom" ).

How to display a horizontal separator in the navbarmenu?

The navbarMenu function also accepts strings, which will be used as menu section headers. If the string is a set of dashes like "----" a horizontal separator will be displayed in the menu.

How to change the text color and background color simultaneously?

@elphlord You change the text color and background color simultaneously by slightly changing your code to this: ui <- navbarPage (title = span ( "My Title", style = "background-color: #DEEBF7; color: red") However, I'm not sure on how to make the background color bigger!


1 Answers

Well, You just need to change the color on this css.

'.navbar-default .navbar-brand {
                         color: #cc3f3f;}'

Here, I changed to #cc3f3f to obtain a red text.

   ui <- function(){

  bootstrapPage('',

                navbarPage(title = 'Hello'),

                tags$style(type = 'text/css', '.navbar { background-color: #262626;
                           font-family: Arial;
                           font-size: 13px;
                           color: #FF0000; }',

                           '.navbar-dropdown { background-color: #262626;
                           font-family: Arial;
                           font-size: 13px;
                           color: #FF0000; }',

                           '.navbar-default .navbar-brand {
                             color: #cc3f3f;
                           }'

                           ))

}

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


shinyApp(ui = ui, server = server)
like image 158
Adelmo Filho Avatar answered Sep 17 '22 13:09

Adelmo Filho