0

I'm running R Shiny and I'm setting a theme:

theme = bs_theme(version = 5, bootswatch = "pulse")

How do I obtain the color codes for the primary color, the secondary color, and so on? I have seen an answer here where the provided CSS code is:

.fa-li {
    color: map-get($theme-colors,"primary")
}

How do I translate this to R code?

SimonSimon
  • 47
  • 6
  • You can run your a dummy app with the `bs_theme` specified and inspect it in your browser. Then search in the inspector for `--bs-primary` etc. – tic-toc-choc Feb 09 '23 at 19:48
  • Yes, but I want to be able to automatically refer to the colors for any theme, i.e. I want to be able to quickly change theme and use the theme colors in ggplot2 objects etc. – SimonSimon Feb 09 '23 at 20:24
  • I doubt you can get those with R. `theme <- bslib::bs_theme(version = 5, bootswatch = "pulse"); str(theme)` references saas files. – tic-toc-choc Feb 09 '23 at 20:27
  • But since R itself can reach these codes, I feel like I should be able to somehow? I know nothing about saas but shouldn't I be able to point R to manually read some file and save the relevant strings from it? – SimonSimon Feb 09 '23 at 20:41
  • It doesn't have to literally be R code, but I want to be able to get the results into my script, maybe I can put the above CSS inline in R somehow to get what I want? – SimonSimon Feb 09 '23 at 20:43
  • 1
    That should be possible with parsing text files in the theme. You might also want to look at https://rstudio.github.io/thematic/ – tic-toc-choc Feb 09 '23 at 20:49
  • Good recommendation, hadn't heard of! :) – SimonSimon Feb 09 '23 at 23:57

0 Answers0