# Using Sass source files

> [Sass](https://sass-lang.com/guide) is a preprocessor that lets you use features that don't exist in standard CSS yet like variables, nesting, mixins and inheritance. These features can make writing custom CSS much faster and more enjoyable.

Source: https://www.zenplates.co/documentation/customization/using-sass-source-files/ (Customization › Introduction)

[Sass](https://sass-lang.com/guide) is a preprocessor that lets you use features that don't exist in standard CSS yet like variables, nesting, mixins and inheritance. These features can make writing custom CSS much faster and more enjoyable.

Our themes let you take full advantage of the power of Sass when editing your theme's styles. The [`style.css` stylesheet](https://www.zenplates.co/documentation/customization/editing-theme-styles) of your theme is a compiled version of the Sass source files contained within the `scss/` directory. Use of Sass is not mandatory and you can edit your theme's `style.css` file directly if you prefer.

## Using Sass

The Sass source files are organized into folders, representing their role in the theming framework:

```text
theme/
└── scss/
  ├── framework/
  │   ├── base/
  │   ├── elements/
  │   ├── utilities/
  │   ├── functions/
  │   ├── mixins/
  │   ├── _variables.scss
  │   └── index.scss
  ├── theme/
  │   ├── _variables.scss
  │   └── index.scss
  └── index.scss
```

- The `framework/` folder contains framework-wide styles and variables.

  - The `base/` folder contains base styles that apply to HTML elements and provide a solid foundation for the styles that come later.

  - The `elements/` folder contains [element styles](https://www.zenplates.co/documentation/elements/understanding-elements) that are reusable blocks of UI which can be combined to create larger layouts.

  - The `utilities/` folder contains [utility classes](https://www.zenplates.co/documentation/utilities/understanding-utilities) that are single purpose styles that can be used to change the look-and-feel of an existing element or layout, or create entirely new layouts from scratch.

  - The `functions/` folder contains all [Sass functions](https://sass-lang.com/documentation/at-rules/function) used by the theming framework.

  - The `mixins/` folder contains all [Sass mixins](https://sass-lang.com/documentation/at-rules/mixin) used by the theming framework.

- The `theme/` folder contains styles and variables specific to the current theme.

### Updating variables

The Sass variables describing every aspect of your theme can be found in the `_variables.scss` Sass partials in the `scss/framework/` and `scss/theme/` folders. You can override existing variable values or define new ones to bring about style changes in your help center.

An example of Sass variables in action is those used to define the gray color palette:

```scss
//
// Gray scale
//
// These are the colors you will use the most and will make up the majority of your UI.
// They're often used for text, backgrounds and borders.
//

$color-gray-100:    #F7FAFC !default;
$color-gray-200:    #EDF2F7 !default;
$color-gray-300:    #E2E8F0 !default;
$color-gray-400:    #CBD5E0 !default;
$color-gray-500:    #A0AEC0 !default;
$color-gray-600:    #718096 !default;
$color-gray-700:    #4A5568 !default;
$color-gray-800:    #2D3748 !default;
$color-gray-900:    #1A202C !default;
```

Using a different shade for `$color-gray-600` could be achieved by adding the following line to your `theme/_variables.scss` file and [recompiling the Sass styles](#compiling-sass):

```scss
$color-gray-600: #656e7b;
```

### Referencing theme settings

When writing custom Sass or CSS you can reference theme settings by using the `identifier` property from the `manifest.json` file as a variable name.

For example, use the `$color_heading` variable to apply the color defined in the **Heading color** theme setting in CSS:

```scss
.h1 {
   color: $heading_color;
}
```

### Referencing theme assets

Theme assets can also be referenced using a variable name, which can be found in the theme's [code editor](https://support.zendesk.com/hc/en-us/articles/4408839332250-Customizing-your-help-center-theme) by following these steps:

1. In Knowledge admin, click the Customize design icon (![Customize icon](https://www.zenplates.co/assets/images/documentation/icon-customize.webp)) in the sidebar.

2. Click **Customize** on the theme you wish to edit.

3. Click **Edit code**.

4. In the Assets folder, click the asset file you want to use.

![Theme assets](https://www.zenplates.co/assets/images/documentation/theme-assets.webp "Theme asset references")

## Compiling Sass

Our themes all include a simple Ruby script for handling the Sass compilation step, which can be found in the `bin/` folder. The script requires both Ruby and the `sassc` gem to be installed.

To start using Sass:

1. Install Ruby on your computer by [following these instructions](https://www.ruby-lang.org/en/documentation/installation/).

2. Install the `sassc` gem using the shell command `gem install sassc`.

Once installed, you can compile your Sass files by running the shell command `./bin/compile.rb` from your theme directory.

The script will take all the `.scss` files inside the `scss/` folder and create a new `style.css` file that is then used by Zendesk Guide. The compiled stylesheet automatically retains references to any [theme settings](https://support.zendesk.com/hc/en-us/articles/4408846524954-Customizing-the-Settings-panel-of-the-theme) and [theme assets](https://support.zendesk.com/hc/en-us/articles/4408829155226-Using-your-own-theme-assets-for-help-center) that you reference in your Sass files.
