Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R bslib change navbar color bootstrap version 5

Tags:

r

sass

shiny

bslib

Why does changing the navbar color not work with BS version 4 and 5 in shiny (version 1.6.0.9022)?

Reproducible example:

app.R

library(shiny)
library(bslib)

theme_test <- bs_theme(version = 5,
                       primary = "#d83e3e") %>%
bs_add_rules(sass::sass_file("custom.scss"))

ui <- navbarPage(title = "Test", theme = theme_test)

server <- function(input, output) {}

shinyApp(ui, server)

custom.scss

.navbar { 
    background-color: $primary;
    color: $primary;
}

run

library(shiny)
runApp("FOLDERNAME")
like image 337
Rob G. Avatar asked Oct 28 '25 05:10

Rob G.


1 Answers

After fiddling around a bit, I found the correct css/sass:

.bg-light, .navbar-default {
    background-color: $primary !important;
}
like image 176
Rob G. Avatar answered Oct 29 '25 19:10

Rob G.