05:00
To keep everyone on the same page, we’ll play with quarto-websites-exercise-site_2025-10
But keep your playground site from yesterday handy!
05:00
Quarto uses the popular Bootstrap library for HTML structure and CSS styles.
You can use Bootstrap components and classes for special styling
↓

Quarto includes 25 themes from Bootswatch:
Specify the custom theme under theme in the YAML settings:
_quarto.yml.07:00
Sometimes we want to change theme settings:
Quarto automatically supports some common Bootstrap theme options
HTML elements can have IDs and classes:
#my-section.special/* All H2s */
h2 {
color: red;
}
/* All elements with id my-section */
/* This includes non H2s */
#my-section {
color: red;
}
/* All H2s with id my-section */
h2#mysection {
color: red;
}
/* All elements with class .special */
.special {
font-style: italic;
}
/* All H2s with class .special */
h2.special {
font-style: italic;
}Explore HTML and CSS right from your browser!
Edit and tinker with styles
See which rule applies
color) andfont-style) andfont-size)05:00
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');
/*-- scss:defaults --*/
/* Built-in Bootstrap variables */
$h2-font-size: 1.6rem !default;
$headings-font-weight: 500 !default;
$font-family-sans-serif: Roboto;
/* Your own variables */
$my-neat-red: #e21818;
/*-- scss:rules --*/
#quarto-sidebar h2 {
font-family: Roboto;
color: $my-neat-red;
/* Magically compiles to #quarto-sidebar h2 a:hover */
a:hover {
color: #d1c81d;
}
}There are so many!
Some examples:
Create a SCSS file and make a bunch of rules!
05:00
You can recreate styles with CSS (site; custom.scss)
Unified branding with a simple YAML file
Create reports, apps, dashboards, plots and more that match your organization’s brand guidelines with a single _brand.yml file.
Learn more: https://posit-dev.github.io/brand-yml/
1. Define branding in a single _brand.yml file.
2. Apply that branding across almost all Quarto formats.
_brand.yml elementsmeta: Identifying information, name of the company, URLs, etc.logo: Files or links to the brand’s logoscolor: Colors in the brand’s color palettetypography: Fonts for different elementsdefaults: Additional context-specific settings_brand.yml structure_brand.yml
meta:
name: Urban Institute
link:
home: https://urbaninstitute.github.io/graphics-styleguide/
logo:
images:
icon:
path: img/urban.png
alt: Urban Institute logo
small: img/urban-sm.png
color:
palette:
blue: "#1696d2"
gray-light: "#d2d2d2"
black: "#000000"
yellow: "#fdbf11"
magenta: "#ec008b"
green: "#55b748"
gray-dark: "#5c5859"
red: "#db2b27"
orange: "#e88e2d"
white: "#ffffff"
background: white
foreground: gray-dark
primary: blue
secondary: yellow
dark: black
typography:
fonts:
- family: Lato
source: google
weight: [400, 700]
- family: Jost
source: google
weight: [400, 700]
base:
family: Lato
weight: 400
headings:
family: Jost
weight: 700
link:
color: primary
decoration: none
defaults:
bootstrap:
functions: # string with SCSS functions
defaults: # list of Bootstrap Sass variables to override
link-hover-color: $brand-magenta
mixins: # string with SCSS mixins
rules: | # string with SCSS rules
#quarto-content h2, #quarto-content h3 {
text-transform: uppercase;
letter-spacing: 1px;
}
.content .highlight {
color: $brand-yellow;
}
.navbar-title {
font-family: Jost;
font-weight: 700;
}_brand.yml in Quarto_brand.yml.Quarto will detect the presence of _brand.yml and automatically apply the brand to all documents of the supported formats in the project.
If your brand file has a different name or lives in a subdirectory, use the brand key.
_brand.ymlTo turn off _brand.yml for a document, use brand: false.
There is a file named urban_institute.yml. Make a copy of it, rename it to _brand.yml, and rerender your site. What changes?
Modify some of the variables in the _brand.yml file and rerender to see how your site changes. Explore the brand.yml documentation and see what other settings you can adjust.
You can reset the file by copying and pasting it from here.
05:00
_brand.yml in MarkdownAccess some _brand.yml values in Quarto documents with a shortcode
↓
The site’s main color is #d7433b
_brand.yml in SassAccess some _brand.yml values with the $brand-* prefix
_brand.yml in R and PythonAccess and apply specific brand elements
The {quarto} package contains theme helpers that apply branding to plots
R + {ggplot2} and Python + plotnine documentation
library(tidyverse)
library(brand.yml)
brand <- read_brand_yml("_brand.yml")
brand_theme <- quarto::theme_brand_ggplot2("_brand.yml") +
theme(
text = element_text(family = brand$typography$fonts[[1]]$family, size = 11)
)
ggplot(mpg, aes(x = displ, y = hwy, color = drv)) +
geom_point() +
labs(title = "A plot") +
scale_color_manual(
values = c(
brand$color$palette$blue,
brand$color$palette$black,
brand$color$palette$yellow
)
) +
brand_themeIn the first code chunk of 01-exercise.qmd, replace theme_minimal() with theme_brand_ggplot2(). You will need to supply a brand file path ("_brand.yml").
Re-render and see what changes.
Change the foreground and background colors in _brand.yml and rerun the code to create the plot. What changes?
05:00
In 01-exercise.qmd, read in _brand.yml with read_brand_yml() from the {brand.yml} package. Store it as a variable named brand.
Change the color of the points to the brand’s blue color and the line to the brand’s magenta color. You’ll use code that looks something like this:
Bonus task! Map a variable from the dataset to the color aesthetic and change the legend to use colors from the brand.
05:00
_brand.ymlSave the file as _brand.yml
Or create a Brand Extension for sharing and distributing your brand
DO NOT try to write a _brand.yml from scratch!
Look at the “Inspiration” page!
Create a brand file for yourself, your project, or your organization.
Don’t try to do this from scratch! Use these resources:
05:00