|
| 1 | +--- |
| 2 | +title: "Brand Extensions" |
| 3 | +--- |
| 4 | + |
| 5 | +Brand extensions are Quarto extensions that provide a [brand.yml](../authoring/brand.qmd) file and its assets. |
| 6 | + |
| 7 | +::: callout-important |
| 8 | + |
| 9 | +Currently, brand extensions merge project-level metadata, so they can only be used with a `_quarto.yml` [project](../projects/quarto-projects.qmd) present in the place where they are installed. This limitation may be lifted in the future. |
| 10 | + |
| 11 | +::: |
| 12 | + |
| 13 | +### Quick Start |
| 14 | + |
| 15 | +Here we'll describe how to create a simple brand extension. We'll use the `quarto create` command to do this. If you are using VS Code, Positron, or RStudio you should execute `quarto create` within their respective integrated Terminal panes. |
| 16 | + |
| 17 | +To get started, execute `quarto create extension brand` within the parent directory where you'd like the brand extension to be created: |
| 18 | + |
| 19 | +```{.bash filename="Terminal"} |
| 20 | +$ quarto create extension brand |
| 21 | + ? Extension Name › my-brand |
| 22 | +``` |
| 23 | + |
| 24 | +As shown above, you'll be prompted for an extension name. Type `my-brand` and press Enter---the brand extension is then created: |
| 25 | + |
| 26 | +```bash |
| 27 | +? Extension Name › my-brand |
| 28 | +Creating extension at /{...}/my-brand: |
| 29 | + - Created _quarto.yml |
| 30 | + - Created README.md |
| 31 | + - Created _extensions/my-brand/brand.yml |
| 32 | + - Created _extensions/my-brand/_extension.yml |
| 33 | + - Created .gitignore |
| 34 | + - Created example.qmd |
| 35 | +? Open With |
| 36 | +❯ positron |
| 37 | + vscode |
| 38 | + rstudio |
| 39 | + (don't open) |
| 40 | +``` |
| 41 | +
|
| 42 | +If you are running within VS Code, Positron, or RStudio a new window will open with the brand project. |
| 43 | +
|
| 44 | +## Contents of Brand Extensions |
| 45 | +
|
| 46 | +Here's what the contents of the files in `_extensions/my-brand/` look like: |
| 47 | + |
| 48 | +``` {.yaml filename="_extensions/my-brand/_extension.yml"} |
| 49 | +title: My-brand |
| 50 | +author: Gordon Woodhull |
| 51 | +version: 1.0.0 |
| 52 | +quarto-required: ">=99.9.0" |
| 53 | +contributes: |
| 54 | + metadata: |
| 55 | + project: |
| 56 | + brand: brand.yml |
| 57 | +``` |
| 58 | + |
| 59 | +``` {.yaml filename="_extensions/mybrand/brand.yml"} |
| 60 | +# minimal brand.yml enabling dark mode |
| 61 | +# replace with your brand colors, logos, and typography! |
| 62 | +color: |
| 63 | + background: |
| 64 | + light: "#fff" |
| 65 | + dark: "#000" |
| 66 | + foreground: |
| 67 | + light: "#000" |
| 68 | + dark: "#fff" |
| 69 | +``` |
| 70 | + |
| 71 | +This is just enough `brand.yml` to enable dark mode. If you preview the `example.qmd` provided in the root of your brand extension |
| 72 | + |
| 73 | +```bash |
| 74 | +quarto preview example.qmd |
| 75 | +``` |
| 76 | + |
| 77 | +you should see the dark mode toggle in the upper right corner, and if you click it you'll see white text on a black background. |
| 78 | +
|
| 79 | +Note that this example, and brand extensions in general, require a `_quarto.yml` project to be present where they are installed. This is because the metadata will be merged via the `project` key. |
| 80 | +
|
| 81 | +We've provided the most basic Quarto project for this example: |
| 82 | + |
| 83 | +``` {.yaml filename="_quarto.yml`} |
| 84 | +project: |
| 85 | + type: default |
| 86 | +``` |
| 87 | +
|
| 88 | +::: {.callout-note} |
| 89 | +
|
| 90 | +The example brand.yml is using the unified light and dark brand feature. Documentation for this feature is on the way. |
| 91 | +
|
| 92 | +Any color in the color or typography sections of [brand.yml](https://posit-dev.github.io/brand-yml/) can be specified with `light` and `dark` components or as a string. If a string, the value is used for both light and dark modes. |
| 93 | +
|
| 94 | +::: |
| 95 | +
|
| 96 | +## How Brand Extensions Work |
| 97 | +
|
| 98 | +The path to the brand file will be resolved relative to the `_quarto.yml` project. |
| 99 | +
|
| 100 | +In turn, any assets such as logos or fonts will be resolved relative to the brand file. |
| 101 | +
|
| 102 | +This way, when the extension is installed in a Quarto project, all paths will eventually be resolved relative to the project. |
| 103 | +
|
| 104 | +The brand is resolved via the `project.brand` key, which is why brand extensions require a `_quarto.yml` project in the place they are installed. The project can be any type. This limitation may be lifted in the future. |
0 commit comments