Skip to content

Commit 9d04547

Browse files
committed
Expand scss section
1 parent 2d0c6d9 commit 9d04547

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

docs/authoring/brand.qmd

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,62 @@ You can't currently access `typography`, `meta`, or `defaults` values using the
442442

443443
### In SCSS
444444

445-
If `_brand.yml` defines `color: blue`:
445+
The colors defined in `palette` are set as SCSS variables of the form `brand-COLOR_NAME`.
446+
For example, if `_brand.yml` defines `blue`:
446447

447448
```{.yaml filename="_brand.yml"}
448449
color:
449450
palette:
450451
blue: "#ddeaf1"
451452
```
452453

453-
This should work:
454+
Then the variable `$brand-blue` is will be set to `#ddeaf1` in the `defaults` layer of [Quarto's SCSS layering system](/docs/output-formats/html-themes-more.html#bootstrap-bootswatch-layering).
455+
You can add a custom SCSS file, `styles.scss`, in the usual way:
456+
```{.yaml filename="_quarto.yml"}
457+
format:
458+
html:
459+
theme: [styles.scss]
460+
```
454461

455-
```{.scss filename="custom.scss"}
462+
Then `styles.scss` can use these brand variables to make style tweaks.
463+
For example, you might want all `h1` elements to be `blue`:
464+
465+
```{.scss filename="styles.scss"}
466+
/*-- scss:rules --*/
467+
468+
h1 {
469+
color: $brand-blue;
470+
}
471+
```
472+
473+
When you specify SCSS files without an explicit `brand` element, it is equivalant to listing them after `brand`.
474+
For instance, the above `theme` is equivalant to:
475+
476+
```{.yaml filename="_quarto.yml"}
477+
format:
478+
html:
479+
theme: [brand, styles.scss]
480+
```
481+
482+
This order doesn't matter when you are setting items in the `/*-- scss:rules --*/` layer, because `rules` are layered on after `defaults`.
483+
484+
However, if you want to set a [Quarto SASS variable](https://quarto.org/docs/output-formats/html-themes.html#sass-variables) you'll use the `/*-- scss:defaults --*/` layer and the order of items in `theme` will matter.
485+
486+
As an example, consider setting the navigation bar background to the `blue` brand color:
487+
488+
```{.scss filename="nav.scss"}
456489
/*-- scss:defaults --*/
457-
$navbar-bg: $brand-blue;
490+
491+
$navbar-bg: $brand-blue;
492+
```
493+
494+
Because of the way Quarto layers SCSS, the order for the `defaults` layer is the reverse of what is specified in `theme`.
495+
For `nav.scss` to find the `brand-blue` variable, `brand` must come after `nav.scss` in `theme`:
496+
497+
```{.yaml filename="_quarto.yml"}
498+
format:
499+
html:
500+
theme: [nav.scss, brand]
458501
```
459502

460503
### Typst

0 commit comments

Comments
 (0)