Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

CL Preview

No security coverage
View on drupal.org

CL Preview is a Drupal-native library browser that allows you to preview and test Single Directory Components (SDC) directly within Drupal, eliminating the need for external build tools like Node.js or Webpack. It automatically discovers components from your themes and modules and provides an organized interface with live previews and hot reloading.

Note: This is an experimental module and is not yet complete. Please avoid opening issues for now.

CL Preview is a Drupal-native component library browser for previewing and testing Single Directory Components (SDC). A great alternative to Storybook that works entirely within Drupal without requiring Node.js, Webpack, or any external build tools.

Features

  • Component Library Browser - Organized interface with navigation and live component previews
  • Hot Reload - Automatically refreshes when component files change
  • Preview Values - Define custom preview data in component.yml for better demos
  • No Story Files - No need for .stories.yml, .stories.json, or MDX files
  • Theme Switching - Preview components in any installed theme
  • Auto-Discovery - Automatically finds SDC components from configured themes/modules
  • No Build Step - Pure Drupal solution with no external tooling required

CL Preview is ideal for frontend developers building design systems, teams documenting component libraries, and projects wanting a native Drupal alternative to Storybook.

Post-Installation

  1. Enable: drush en cl_preview -y
  2. Configure: /admin/config/development/cl-preview/settings
    • Select themes/modules to scan for components
    • Choose preview theme (optional)
    • Enable hot reload (optional)
  3. View Library: /admin/config/development/cl-preview
  4. Permissions: Grant "Access CL component library" to appropriate roles

Improving Preview Display with Preview Values

By default, components may render with empty or minimal data if they only have basic defaults. To create better demonstrations in the component library, add a preview section to your existing *.component.yml files with meaningful sample data. No separate story files needed!

# your-component.component.yml
props:
  type: object
  properties:
    title:
      type: string
      default: ''
    variant:
      type: string
      default: primary

# Add preview values for better demos
# No need for .stories.yml or .stories.json files!
preview:
  title: Example Title
  description: Sample content
  variant: primary

Preview Value Hierarchy: The module uses preview values first, then falls back to prop defaults, then type-based defaults (empty string, 0, false, [], etc.). This means your preview section will override any defaults defined in the props, giving you complete control over how components appear in the library.

The preview page will highlight props with empty values in red to help you identify which components need better preview data. See the full README for more details.

Additional Requirements

  • Drupal 10.1+ with SDC module (core)
  • At least one theme or module with SDC components (components/ directory with *.component.yml files)

Comparison

Why CL Preview is a great alternative to Storybook:

  • No Node.js, Webpack, or build tools required
  • No separate installation or deployment
  • No .stories.yml, .stories.json, or MDX files to create or maintain
  • Native Drupal integration using the render system
  • Automatic component discovery from existing .component.yml files

vs. SDC Examples: Hot reload, organized library interface

vs. Pattern Lab: No separate installation, works directly with Drupal's SDC system

Community Documentation

Full documentation including troubleshooting, value hierarchy, interactive features, and extending the module is available in the module's README.md file.

Credits

Co-authored with Claude Code - AI pair programming assistant by Anthropic.

Activity

Total releases
1
First release
Oct 2025
Latest release
8 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
1.0.x-dev Dev Oct 28, 2025