2.1 Dark Theme

https://community.rstudio.com/t/fvaleature-req-word-background-highlight-color-in-find-and-spellcheck/18578/3

https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html

https://docs.posit.co/ide/user/ide/guide/ui/appearance.html#creating-custom-themes-for-rstudio

Theme repositories

RStudio and Editor themes are two differnt things

Useful elements:

.ace_marker-layer .ace_selection Changes the color and style of the highlighting for the currently selected line or block of lines.

.ace_marker-layer .ace_bracket Changes the color and style of the highlighting on matching brackets.

Recommended highlight color: rgba(255, 0, 0, 0.47)

If you really like one of the default themes RStudio provides, but you want to tweak some small things, you can go the theme directory and change the element’s appearance.

RStudio’s default editor theme directory on Mac:

Right click RStudio.app, “Show Package Contents” to navigate to the application folder.

/Applications/RStudio.app/Contents/Resources/resources/themes/ambiance.rstheme (deprecated)

New editor theme directory: /Applications/RStudio.app/Contents/Resources/app/resources/themes/ambiance.rstheme

You may also find the default themes on GitHub repo: https://github.com/rstudio/rstudio/tree/master/src/cpp/session/resources/themes

If you want to install or create a completely new theme, use the Custom theme (user-defined) folder:

  • ~/.config/rstudio/themes/idle_fingers_2.rstheme on mac
  • viridis-theme
/* yaml tag */
.ace_meta.ace_tag {
  color: #2499DA;
}
/* quoted by $...$ and code chunk options */
.ace_support.ace_function {
  color: #55C667;
}

See HERE for common selectors you can use.

A collection of screenshots of default RStudio themes: https://www.trifields.jp/list-of-rstudio-editor-themes-2520

Q: The margin line is too bright.
A: Change the .ace_print-margin element.

.ace_print-margin {
  width: 1px;
  background: #e8e8e8;
}

#e8e8e8 is the culprit here, and should be darkened. I changed it to #2F3941.

Source: https://github.com/rstudio/rstudio/issues/3420#issuecomment-453154475

Install custom themes

  • Using rstudiothemes pkg

    Go to the repository to see which theme you want to use. Then install the theme. Themes can be applied to RStudio via “Tools” - “Global Options” - “Appearance” - “Add Theme”.

    # install the pseudo-package from this Github repository
    devtools::install_github("max-alletsee/rstudio-themes")
    
    library(rstudiothemes) # ... then load the library
    
    # example 1: bulk-install all light themes
    install_rstudio_themes(theme = "all_light")
    
    # example 2: install two specific light themes
    install_rstudio_themes(theme = c("Ayu Light", "Github {rsthemes}"))
    
    # examplease 3: install one specific dark theme
    install_rstudio_themes(theme = "49th Parallel")
  • Using rstudioapi package’s “addTheme” function

    # create temporary download directory
    theme_49th_parallel <- fs::path_temp("49th_parallel-RStudio", 
                                         ext = "rstheme")
    
    # download theme from github
    download.file("https://raw.githubusercontent.com/wvictor14/rstudio_themes/master/49th%20Parallel.rstheme", 
                  theme_49th_parallel)
    
    # apply the theme
    rstudioapi::addTheme(theme_49th_parallel, 
                         apply = TRUE)