Media

Under media, you can find some of the media-related styles.

Images

In Spruce, we use a general responsive styling for all images. We also disable the user-select. Give images a radius globally with the img-border-radius key of the $media map (new in v3).

A sandy beach with teal colored water from above.
img {
    block-size: auto;
    display: block;
    max-inline-size: 100%;
    user-select: none;
}

Video

New in v3. Videos are responsive too: they never overflow their container and keep their aspect ratio.

<video controls width="1280" height="720" poster="poster.jpg">
    <source src="video.mp4" type="video/mp4">
</video>

Figure

To create an image caption, use the figure and figcaption elements. The figure margin is reset, and the caption is centered below the image (no classes needed).

A sandy beach from above with a lot of colorful sunshades.
The beach where we were sunbathing last summer.
<figure class="figure">
    <img src="..." alt="..."/>
    <figcaption class="figure-caption">The beach where we were sunbathing last summer.</figcaption>
</figure>

Caption Options

New in v3. Configure the captions with the $media map:

@use 'sprucecss/scss/spruce' with (
  $media: (
    'figcaption-font-size': 0.875rem,
    'figcaption-font-style': italic,
    'figcaption-margin-block-start': 0.75rem,
    'figcaption-text-align': start,
    'img-border-radius': 0.5rem,
  ),
);

Iframes

Iframes are block elements that fill their container. Wrap them in an element with an aspect-ratio to keep the proportions:

<div style="aspect-ratio: 16 / 9;">
    <iframe src="https://www.youtube-nocookie.com/embed/..." title="Video title" allowfullscreen></iframe>
</div>

Documentation

Learn about Spruce CSS through our extensive documentation.

Components

Explore our UI library of accessible components built with Spruce CSS.

Blocks and Pages

Full-width page blocks and complete page templates, ready to copy.

Find us on GitHub

Did you find a bug? Have an idea or a question? Please open an issue to help us develop the project.