Open
Description
Hi
Is it possible to allow usage of built-in Sass modules? quarto cli discussion #12254 might be helpful.
Here is some starter code for the subsequent examples.
library(bslib)
library(shiny)
custom_theme <- bs_theme(version = 5)
# UI ---------------------------------------------------------------------------
ui <- page_navbar(
theme = custom_theme,
nav_panel(
"One",
card(
card_header("card header goes here", class = "bg-aaa"),
"card content goes here"
)
),
nav_panel("Two"),
nav_panel("Three")
)
# Server -----------------------------------------------------------------------
server <- function(input, output) {
}
# Run the application ----------------------------------------------------------
shinyApp(ui = ui, server = server)
In the bslib getting started theming Variables docs we find the example
bs_theme("progress-bar-bg" = "mix(white, orange, 20%)")
We can use the deprecated lighten()
function (deprecated as mix()
above, but it's less illustrative for mix()
) to turn the navbar slightly orange.
custom_theme <- bs_theme(
version = 5,
bg = "white",
"navbar-bg" = "lighten(#e06d33, 30%)",
fg = "black"
)
How can we @use
the Sass color module's scale()
?
custom_theme <- bs_theme(
version = 5,
bg = "white",
"navbar-bg" = "color.scale(#e06d33, $lightness: 50%)",
fg = "black"
)
Similarly, this works
custom_theme <- bs_theme(version = 5) |>
bs_add_variables("aaa" = "#e06d33") |>
bs_add_rules(
"
.bg-aaa {
background-color: lighten($aaa, 20%);
}
"
)
But we wished to do
custom_theme <-bs_theme(version = 5) |>
bs_add_variables("aaa" = "#e06d33") |>
bs_add_rules(
"
.bg-aaa {
background-color: color.scale($aaa, 50%);
}
"
)
or
custom_theme <- bs_theme(version = 5) |>
bs_add_variables("aaa" = "#e06d33") |>
bs_add_rules(
"
@use 'sass:color';
.bg-aaa {
background-color: color.scale($aaa, 50%);
}
"
)
Metadata
Metadata
Assignees
Labels
No labels