Introduction
Backdrops provide a simple way to place a translucent image behind contextual content. Backdrops offer two style variants: Image Proportional and Fixed Height.
Backdrops remove the need for using CSS background images. Feature images exist within the HTML, so screen readers can read the text of the image's alt attribute.
Video backdrops respect users' reduced motion settings. This ensures a smoother, more comfortable experience for those who have opted for less motion on their devices..
Image Proportional
Image-proportional backdrops adjust automatically to different screen sizes. Below is an example of a basic Image Proportional backdrop.
Line # | Details |
---|---|
1 | The parent The |
3-11 | The The |
13-24 | The |
The size of this backdrop (proportional width and height) is determined by the size of its feature image.
The translucent effect of the backdrop is achieved with additional utility classes. Our theme color utilities (e.g., .theme-dark
) set the background and text color. The opacity utility class (e.g., .opacity-30
) applied to the backdrop's feature image allows the background color to show through.
Stack Breakpoint Modifiers
When using image size proportional backdrops for featured content (like the full-width example below), the backdrop may become too tall for the image on smaller viewport sizes.
Photo by Aniket Deole
The mountain at a given distance In amber lies
—Excerpt from Delight becomes pictoral
To adjust for small screens, add a stack breakpoint modifier (e.g., .backdrop--stack--{x}
) to the .backdrop
class. Where x is the desired breakpoint (e.g., lg for large). The backdrop's image is placed above the content vertically until the viewport reaches the specified breakpoint.
Resize your browser window to see this in action. Notice the image is at full opacity because opacity utilities have their own breakpoint modifiers. Adding .opacity-40--lg
to the .backdrop__media
class gives that image a specified opacity (40%) at the large (lg) breakpoint.
Figure 2 below provides the code used to create the backdrop above. Refer specifically to line 1, where the .backdrop--stack--lg
breakpoint modifier is present.
All of this together makes it easy to create responsive backdrops with different themes and content. What if we don't want our backdrop's size to be dictated by its feature image?
Fixed Height
Fixed Height backdrops maintain their height across different viewport sizes. They adjust to the height of their inner content.
For a fixed height backdrop, add the .backdrop--fixed
class to the .backdrop
element.
Photo by Jane Doe on Unsplash
The Mountain sat upon the Plain
The .backdrop--fixed
class stretches to fit the content within .backdrop__cover
. Consider the following layout:
Photo by Alberto Restifo
Nature in Poetry
Featured Poem
This—is the land—the Sunset washes—
This—is the land—the Sunset washes—
These—are the Banks of the Yellow Sea—
Where it rose—or whither it rushes—
These—are the Western Mystery!
Night after Night
Her purple traffic
Strews the landing with Opal Bales—
Merchantmen—poise upon Horizons—
Dip—and vanish like Orioles!
Video Backdrop
The Backdrop component can also include a video as its feature media. By using the .backdrop__media
class to contain a video element, you can create a dynamic and visually appealing backdrop that plays automatically when users access the page.
Below is an example of a Backdrop with a video as the feature media, including a media control button:
To ensure the video respects users' preferences regarding reduced motion, you can include an optional control element using the .backdrop__media__control
selector. This control allows users to pause the video if they prefer to limit motion effects. The button inside .backdrop__media__control
must have the data-check-reduced-motion
attribute, which automatically pauses the video and displays the poster image first for users who have enabled the "reduce motion" setting in their system preferences.
Line # | Details |
---|---|
5-8 | The The |
13-19 | The |