Skip to content

Commit a2e501d

Browse files
dark brand docs
1 parent 4491934 commit a2e501d

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

docs/authoring/brand.qmd

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,44 @@ brand: brand/_brand.yml
7373

7474
Paths specified in `_brand.yml` are relative to the location of the brand file.
7575

76+
### Dark Brand
77+
78+
As with [Themes](/docs/output-formats/html-themes.qmd#dark-mode), you can specify both light and dark brands, making both a light and a dark version of your output available:
79+
80+
```{.yaml filename="document.qmd"}
81+
---
82+
brand:
83+
light: light-brand.yml
84+
dark: dark-brand.yml
85+
---
86+
```
87+
88+
This also works with brands specified directly in the document:
89+
90+
```{.yaml filename="document.qmd"}
91+
---
92+
brand:
93+
light:
94+
color:
95+
background: "#ffffff"
96+
foreground: "#333333"
97+
dark:
98+
color:
99+
background: "#333333"
100+
foreground: "#ffffff"
101+
---
102+
```
103+
104+
Light and dark brands can also be specifieds in a project:
105+
106+
```{.yaml filename="_quarto.yml"}
107+
---
108+
brand:
109+
light: light-brand.yml
110+
dark: dark-brand.yml
111+
---
112+
```
113+
76114
## Brand Elements
77115

78116
The elements of **brand.yml** are specified in the documentation for the [**brand.yml** project](https://posit-dev.github.io/brand-yml/){.external}.
@@ -411,7 +449,7 @@ Beyond the automatic application of your brand file, you can also directly acces
411449

412450
Some values from the `_brand.yml` configuration file can be accessed via the `brand` shortcode. In particular, you can access colors and logos by name:
413451

414-
- Use `{{{< brand color COLOR_NAME >}}}` to return the brand color named `COLOR_NAME` as a string.
452+
- Use `{{{< brand color COLOR_NAME BRAND_MODE >}}}` to return the brand color named `COLOR_NAME` as a string. Provide `dark` for `BRAND_MODE` in order to return the color from the [dark brand](#dark-brand); otherwise the light brand will be used.
415453
- Use `{{{< brand logo LOGO_NAME >}}}` to return the brand logo named `LOGO_NAME` as an image.
416454

417455
For example, you could use the shortcode to place a brand image you've named `icon` in a dashboard sidebar:
@@ -558,4 +596,17 @@ theme:
558596
- tweaks.scss # a user-defined customization
559597
```
560598
599+
The analogous syntax also works for combining light and dark brands with light and dark themes:
600+
601+
```yaml
602+
# Quarto 1.7 syntax
603+
theme:
604+
light:
605+
- cosmo
606+
- brand
607+
dark:
608+
- slate
609+
- brand
610+
```
611+
561612
Learn more about how Quarto generates styles in [More About Quarto Themes](/docs/output-formats/html-themes-more.qmd).

docs/output-formats/html-themes.qmd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ Setting the above themes in your `_quarto.yml` results in both a dark and light
101101

102102
When providing both a dark and light mode for your html output, Quarto will automatically create a toggle to allow your reader to select the desired dark or light appearance. The toggle will automatically appear in the top right corner of your html output. When possible, the toggle will use browser local storage to maintain the user's preference across sessions.
103103

104-
The first appearance (light or dark) elements in the theme to determine the default appearance for your html output. For example, since the `light` option appears first in the above example, a reader will see the light appearance by default.
104+
To honor the user's operating system or browser preference for light or dark mode, specify `respect-user-color-scheme: true`. Otherwise, the order of light and dark elements in the theme or brand will determine the default appearance for your html output. For example, since the `light` option appears first in the above example, a reader will see the light appearance by default, if `respect-user-color-scheme` is not enabled.
105105

106106
Quarto will automatically select the appropriate light or dark version of the text highlighter that you have specified when possible. For more information, see [Code Highlighting](html-code.qmd#highlighting).
107107

108+
As of Quarto 1.7, `respect-user-color-scheme` applies on page load, and the page won't change if dark mode is changed dynamically. It also requires JavaScript support: users with JavaScript disabled will see the author-preferred (first) brand or theme.
109+
108110
### Customizing Themes
109111

110112
As when providing a single theme, you may provide a custom theme for dark and light mode, or a list of `scss` files to customize the light and dark appearance. This website, for example uses the following to use a light `cosmo` theme and then customizes the `cosmo` theme with additional Sass variables when in dark mode:

docs/prerelease/1.7/_highlights.qmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ Quarto 1.7 includes the following new features:
66
- [Caching](/docs/computations/julia.qmd#caching-julia): Save time rendering long-running notebooks by caching results.
77
- [Revise.jl integration](/docs/computations/julia.qmd#revise.jl-integration): Automatically update function definitions in Julia sessions.
88

9+
- Improvements to dark mode:
10+
- [Dark Brand](/docs/authoring/brand.qmd#dark-brand): Light and dark brands can be specified for a document or project, enabling dark mode via brand.yml.
11+
- [`respect-user-color-scheme`](/docs/output-formats/html-themes.qmd#dark-mode): If enabled, this option detects the user's operating system / browser preference for whether to show the page in light or dark mode.

0 commit comments

Comments
 (0)