Skip to main content

Views Flexbox: Drupal 8 views style plugin

/** * @file * * Available variables: * - attributes: HTML attributes for the containing element. * - label_hidden: Whether to show the field label or not. * - title_attributes: HTML attributes for the label. * - label: The label for the field. * - content_attributes: HTML attributes for the content. * - items: List of all the field items. Each item contains: * - attributes: List of HTML attributes for each item. * - content: The field item's content. * - entity_type: The entity type to which the field belongs. * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. * * @see template_preprocess_field() * @see whirr_preprocess_field__entity_reference() */ #} Drupal 8 /** * @file * * Available variables: * - attributes: HTML attributes for the containing element. * - label_hidden: Whether to show the field label or not. * - title_attributes: HTML attributes for the label. * - label: The label for the field. * - content_attributes: HTML attributes for the content. * - items: List of all the field items. Each item contains: * - attributes: List of HTML attributes for each item. * - content: The field item's content. * - entity_type: The entity type to which the field belongs. * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. * * @see template_preprocess_field() * @see whirr_preprocess_field__entity_reference() */ #} Flexbox

We're not entirely convinced that a View Flexbox plugin is required - it's a fairly simple matter to apply Flex attributes to view container divs and views row items, and get the desired result. Furthermore, you could theoretically achieve much of the work Flexbox requires by using the Views Bootstrap plugin, and overriding a few of its templates.

But where's the fun in that? So we've committed a very early version of a formal Views Flexbox plug-in at Github. The CSS included at the repo is very closely based on Lee Jordan's Reflex project.

We'll update this article with details about the modules capabilities and limitations. In the meantime we invite anyone interested to experiment with the module, suggest improvements, or fork the code. Eventually, if there is a demand, we'll start the process of posting this little project to Drupal.org as a formal module.