Using Themes in the RStudio IDE

Follow

Switching Themes

RStudio provides support for three global themes that customize the RStudio IDE's user interface: Classic, Modern and Sky. By default, the Modern theme is selected.

To switch between themes, from the "Global Options" menu, use the "RStudio theme" dropdown:

Screen_Shot_2017-08-24_at_1.14.19_PM.png

Modern Theme

The modern theme uses a similar color palette to RStudio 1.0, but flattens all user interface elements: Panels, buttons, dialogs, etc. making it looks as follows:

Screen_Shot_2017-08-24_at_1.22.05_PM.png

Sky Theme

The Sky theme is similar to the Modern theme, except for the tab and toolbar headers:

Screen_Shot_2017-08-24_at_1.23.05_PM.png 

Dark Theme

The dark theme is a superset to the Modern and Sky themes that is activated whenever the Editor theme uses a dark palette.

Screen_Shot_2017-08-24_at_1.22.41_PM.png

Classic Theme

The Classic theme does not flatten any of the elements in the user interface and looks the in the same way that RStudio 1.0 and other versions used to look like:

Screen_Shot_2017-08-24_at_1.42.31_PM.png

Custom Editor Themes

Add a Theme

RStudio provides support for adding custom editor themes in one of two formats: tmTheme or rstheme. The tmTheme format was first introduced for TextMate, and has since become one of the standard formats for themes. This tmTheme editor also includes a large collection of tmThemes. The rstheme format is specific to RStudio.

To add a custom editor theme, navigate to the Appearance Preferences Pane in Global Options:

2018-10-29-import-theme-steps-3-and-4.png

Next, click the "Add..." button and choose the desired tmTheme or rstheme file. If you are prompted to install R packages, select "Yes".

import-theme-step-5.png

Now you should see your custom theme in the list of editor themes. Simply select the theme as described in the Switching Themes section of this article.

import-theme-step-6.png

2018-10-29-night-owl.png

Custom editor themes can be added either for the current user or for all users. Adding a theme from the Global Options UI will always add it for the current user. To add a theme for all users, see the Themes API section.

Remove a Theme

Custom editor themes can also be removed from RStudio. To do so, start by navigating back to the Appearance Preferences Pane in Global Options and select the theme you wish to remove from the list of editor themes. If the theme is a custom theme, the "Remove" button should become active. If the theme you wish to remove is currently active, you must switch to a different theme before being able to remove it.

2018-10-29-remove-theme-step-1.png

Click the remove button, and then click yes when prompted. Keep in mind that removing a theme is a permanent action, and cannot be undone.

2018-10-29-remove-theme-step-2.png

After you click "Yes", the theme should be removed from RStudio.

Making and Sharing Themes

If you'd like to make and share your own themes, here's the path we recommend:

  1. Start with a tmTheme file. You can make one using an online tmTheme editor
  2. Convert the tmTheme file to an .rstheme file. This can be done using the RStudio Themes API, rstudioapi::convertTheme.
  3. The .rstheme file is a plain-text CSS file that will be applied to the IDE, and it can contain any CSS you like. Open the CSS file in RStudio and make any additional tweaks you need.
  4. Upload the .rstheme file to a static file host such as Github so that it has a URL.

Once uploaded, you can encourage people to try out your theme by running:

rstudioapi::addTheme("http://your-theme-url/", apply = TRUE)

This command will download, install, and apply the theme in a single step. (They can also download the theme and open it in RStudio using the Add button as described above). 

Read more about creating custom themes for RStudio.

Themes API

For those interested in authoring packages or integrating themes programmatically, you can make use of the rstudioapi package. At the time of this writing, this will require using the development verison of this package by running:

devtools::install_github("rstudio/rstudioapi")

Then we can query the current theme using:

rstudioapi::getThemeInfo()

which, for the Modern theme and Xcode this function would return:

$editor
[1] "Xcode"
$global
[1] "Modern"
$dark
[1] TRUE

This can be used to properly customize the output from your package to match the RStudio theme selected by each user.

 

Note: The following functions are only available in RStudio Preview, 1.2 or above.

To add a new rstheme, use:

rstudioapi::addTheme(themePath, apply, force, globally)

which returns the name of the newly added theme. It's parameters are described below:

Parameter Description
themePath A full or relative path or URL to the rstheme file to add.
apply Whether to immediately apply the newly added theme. Default: FALSE.
force Whether to force the add operation if a file with the same name already exists. Default: FALSE.
globally Whether to add the theme for all users (TRUE) or the current user (FALSE). Default: FALSE.

 

To add a new tmTheme, use:

rstudioapi::convertTheme(themePath, add, outputLocation, apply, force, globally)

which also returns the name of the newly added theme. It's parameters are described in the table below:

Parameter Description
themePath A full or relative path to the tmTheme file to add.
add Whether to add the converted theme to RStudio immediately. Default: TRUE.
outputLocation A full or relative path where an additional copy of the converted theme will be saved. If this value is not set and add is set to FALSE, no file will be saved. Default: NULL.
apply Whether to immediately apply the newly added theme. Default: FALSE.
force Whether to force the add operation if a file with the same name already exists. Default: FALSE.
globally Whether to add the theme for all users (TRUE) or the current user (FALSE). Default: FALSE.

 

To apply a particular theme use:

rstudioapi::applyTheme(name)

where name is the name of theme returned by rstudioapi::getThemes().

 

To remove a custom theme use:

rstudioapi::removeTheme(name)

where name is the name of theme returned by rstudioapi::getThemes().

 

To list all the available editor themes, use:

rstudioapi::getThemes()

which returns a list of themes in the format id = list(name = "a theme name", isDark = TRUE). For example, some values in the list would look like:

$`ambiance`
$`ambiance`$`name`
[1] "Ambiance"

$`ambiance`$isDark
[1] TRUE


$chaos
$chaos$`name`
[1] "Chaos"

$chaos$isDark
[1] TRUE


$chrome
$chrome$`name`
[1] "Chrome"

$chrome$isDark
[1] FALSE

Comments

  • Avatar
    peljasz

    hi,
    Is it possible to theme the interface/menu/icons/fonts?
    many thanks, L.