SCSS

Nextcloud supports SCSS natively. You can migrate your files by simply renaming your .css files to .scss. The server will automatically compile, cache and serve it. The SCSS file is prioritized. Having two files with the same name and a scss & css extension will ensure backwards compatibility with <12 versions as scss files will be ignored by the server.

CSS variables

App developers should use CSS4 variables so you get the values which Nextcloud defines. This way you can be sure that the theming and accessibility app can dynamically adjust the values.

A list of available variables is listed in the server repository: https://github.com/nextcloud/server/blob/master/core/css/css-variables.scss

SCSS icon mixins

Some SCSS mixins and functions are employed to add and manage SVG icons.

These functions need to be used to add the icons via background-image. They create a list of every icon used in Nextcloud and create an associated list of variables. This allows us to invert the colors of the SVGs when using the dark theme.

  1. /**
  2. * SVG COLOR API
  3. *
  4. * @param string $icon the icon filename
  5. * @param string $dir the icon folder within /core/img if $core or app name
  6. * @param string $color the desired color in hexadecimal
  7. * @param int $version the version of the file
  8. * @param bool [$core] search icon in core
  9. *
  10. * @returns string the url to the svg api endpoint
  11. */
  12. @mixin icon-color($icon, $dir, $color, $version: 1, $core: false)
  13. // Examples
  14. .icon-menu {
  15. @include icon-color('menu', 'actions', $color-white, 1, true);
  16. // --icon-menu: url('/svg/core/actions/menu/ffffff?v=1');
  17. // background-image: var(--icon-menu)
  18. }
  19. .icon-folder {
  20. @include icon-color('folder', 'files', $color-black);
  21. // --icon-folder: url('/svg/files/folder/000000?v=1');
  22. // background-image: var(--icon-folder)
  23. }

More information about the svg color api.

The icon-black-white mixin is a shortand for the icon-color function but it generates two sets of icons with the suffix -white and without (default black).

  1. /**
  2. * Create black and white icons
  3. * This will add a default black version of and an additional white version when .icon-white is applied
  4. */
  5. @mixin icon-black-white($icon, $dir, $version, $core: false)
  6. // Examples
  7. @include icon-black-white('add', 'actions', 1, true);
  8. // Will result in
  9. .icon-add {
  10. @include icon-color('add', 'actions', $color-black, 1, true);
  11. }
  12. .icon-add-white,
  13. .icon-add.icon-white {
  14. @include icon-color('add', 'actions', $color-white, 1, true);
  15. }