Breakpoint API in Drupal

Drupal's Breakpoint API defines responsive design breakpoints to ensure a consistent and optimized layout across different devices, enhancing the site's usability and accessibility.

This course covers the fundamentals of breakpoints and media queries, the structure and purpose of breakpoint YAML files, and practical steps to create and implement these files in Drupal themes or modules. By the end of the course, learners will be able to expose their site's breakpoints to other Drupal modules and themes, enabling responsive design features such as responsive image styles.

Key topics

  • Introduction to breakpoints and media queries
  • Creating a breakpoint YAML file
  • Practical application and testing
Tutorials in this course
Categories
Drupal 8, 9, and 10
More information

You've got a slick responsive theme for your Drupal site that's been implemented in CSS using media queries. But the content and images on your site will regularly be updated and you want to use the Responsive Images module to create responsive image style field formatters that you can apply to image field display settings.

In this lesson, we'll review the concepts of breakpoints and media queries so that you can better understand what's going on when you encounter them in non-CSS file contexts like configuration forms for responsive image styles or breakpoint YAML files.

By the end of this tutorial, you should have an understanding of what breakpoints are, how they are expressed in media queries, and how they are relevant in the context of Drupal.

Categories
Drupal 8, 9, and 10
More information

Drupal's Breakpoint module defines a "breakpoint" plugin type that modules or themes can implement via a breakpoints configuration file. So, in order to make their breakpoints discoverable, themes and modules define their breakpoints in a THEME-OR-MODULE.breakpoints.yml file located in the root of their directory.

In this tutorial, you'll learn about the structure of a breakpoints configuration file and why you would want to use one. We’ll cover the kinds of metadata you can include in a breakpoint file, including key, label, mediaQuery, weight, multipliers, and breakpoint group. Throughout, we'll look at some examples of breakpoint configuration files available in Drupal themes and modules.

Categories
Drupal 8, 9, and 10
More information

As we learned in the What Is a Breakpoints YAML file? tutorial, modules and themes can expose their site's CSS breakpoints and media queries to other Drupal modules and themes by implementing a breakpoints YAML file. In that tutorial, you also learned about the structure of a breakpoints configuration file and why you'd want to create one. In this tutorial, we’ll walk through the process of creating an example breakpoints file step-by-step.

By the end of this lesson, you should be able to create a working breakpoints YAML file in a theme or module. We'll test it out by enabling Drupal's Responsive Image module, where we'll be able to see it listed in the configuration form for creating a new responsive image style.

This course appears in the following guides:
Site Administration
Learn to manage media and create responsive image styles.

Media and Responsive Images