WordPress plugin intelligence profile

Responsive Containers

Responsive Containers provides a framework for applying styles to blocks & widgets based on how large they appear on screen.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 5.2
Current version1.1.0
WordPress coverageTested up to WordPress 5.2
Minimum stackWP 5.2.0 · PHP 5.6.20
Directory statusactive
Last directory update20 Jul 20197y ago
Active installations10Adoption metric — not a quality score
WordPress.org ratingNo WordPress.org ratings yet
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Responsive Containers version 1.1.0 as active, updated 7y ago and tested up to WordPress 5.2.

Overview

About this plugin

CSS media queries let us style elements based on the size of the screen. What if we wanted to style them based on the size of their container? A widget or block should often look different if it’s full-width or constrained within a column or sidebar, but we didn’t have any way to write container queries to style those elements based on their on-screen width… until now!

This plugin loads a small JavaScript file that conditionally applies classes to elements based on how wide those elements are in the browser. This can be used by other themes and plugins to write container-specific styles for editor blocks or widgets, so that they will display correctly wherever they are placed in the page.

The script works on the frontend and in the block editor — see your responsive styles live while you’re composing your post, and trust that your widgets and blocks will look their best whether they’re full-width or in the narrowest sidebar.

Usage

If you have a block or widget in your site that you wish to use as a responsive container, add the data-responsive-container attribute to that block’s container element. For example, the parent <div> for a calendar block might look like this:

<div class="calendar-block" data-responsive-container>

By adding that data-attribute and nothing more, your container will now be tagged with additional classes based on how big they appear:

– No special class if the container is below 420px (style for this narrow context as your default).

– container-sm if the container is 420px wide or more,

– container-md if it is wider than 600px,

– container-lg if it is wider than 720px, and

– container-xl for any element 960px or wider.

These are default values and therefore somewhat arbitrary, so you may also provide your own custom theme- or plugin-specific breakpoint values using the data-responsive-container attribute. When rendering your element or block in PHP, pass an array of class names and the minimum width at which each class should be applied. container-* classes, or they may be specific to the element being styled:

echo sprintf( '<div class="myblock" data-responsive-container="%s">', esc_attr( wp_json_encode( [ 'myblock--2-column' => 600, 'myblock--3-column' => 900, ] ) );

myblock--3-column at or above 900px.

myblock element receives no custom class below 600px. We don’t apply any class names below your specified minimum because we assume styles are written narrow-context-first, but you may ensure your smallest class is always applied by providing a minimum width of 0:

echo sprintf( '<div class="myblock" data-responsive-container="%s">', esc_attr( wp_json_encode( [ 'myblock--1-column' => 0, // Will apply in all circumstances. 'myblock--2-column' => 600, 'myblock--3-column' => 900, ] ) );

From within WordPress

  • Visit ‘Plugins > Add New’
  • Search for ‘Responsive Containers’
  • Activate the Responsive Containers plugin from your Plugins page.
  • Start using data-responsive-container attributes within your theme or plugin.

Manually

  • Upload the responsive-containers folder to the /wp-content/plugins/ directory
  • Activate the Responsive Containers plugin from your Plugins page.
  • Start using data-responsive-container attributes within your theme or plugin.

License & Attribution

This plugin is licensed under the terms of the GNU General Public License (or “GPL”). It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

It was created by K. Adam White at Human Made, based on a concept popularized by Philip Walton.

This plugin utilizes the resize-observer-polyfill library by Denis Rul, released under the MIT license and &copy; 2016 Denis Rul.

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • container queries
  • responsive containers
  • responsive design
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 5.2

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 5.2.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to5.2
Minimum requirementsWordPress 5.2.0 · PHP 5.6.20
Update activity20 Jul 20197y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.