Overview

Classy paragraphs ships a new field type "Class list" which allows an editor to apply a selected class to paragraphs via a drop-down list.

Installation

Drupal 7

- Enable Classy paragraphs
- Add "Class list" field to desired paragraph type
- Defines classes by implementing the the hook_classy_paragraphs_list_options hook.

Optional:
- Install classy_paragraphs_ui to manage classes from a user interface. Thanks go to Mark Breneman for writing this useful module.

Drupal 8

- Enable Classy paragraphs
- Go to admin/structure/classy_paragraphs_style and create a style.
- Create a reference field and target "classy paragraphs style."
- Select style and the classes should appear.

How It Works

Drupal 7

This module allows an editor to select a class, via a drop-down list, which is added to the paragraph template.

The class is added to the template via the classy_paragraphs_preprocess_entity preprocess function. In this function we use classy_paragraphs_get_class to pull out the selected class from the paragraph_item entity. Once we have a class, then we add it to the template using $variables['classes_array'].

Drupal 8

We've refactored the module so it uses Drupal 8's new config entity. By doing this we can export CSS classes (called styles), we get a UI to manage the classes and NO MORE hooks. Also, you can add multiple classes to a single style.

NOTE: The module won't work if you're using Display Suite or Panelizer to configure the paragraphs. Integration will come later.

Requirements

Upgrades

While this modules is in alpha, there will be no database upgrade support.

Demo

Check out our Paragraphs demo site to see this module in action.

Supporting organizations: 
Initial Drupal 7 development.
Drupal 8 Development.

Project Information

Downloads