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). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). 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.

SVG.js

No security coverage
View on drupal.org

This project integrates the SVG.js library into Drupal, allowing for easy creation, manipulation, and animation of SVG graphics. It provides a clean JavaScript API that can be used in themes, modules, or inline for interactive visuals without requiring complex configuration.

SVG.js for Drupal integrates the SVG.js library with Drupal, giving site builders and developers a lightweight way to create, manipulate, and animate SVG graphics on any page. It works out of the box and can load SVG.js from a CDN or a local copy, exposing a clean JavaScript API for interactive visuals.

Features

  • Zero-config default: Enable the module and start using SVG.js immediately.
  • Flexible library source: Auto-detect a local library or fall back to a trusted CDN.
  • Rich SVG API: Create shapes, apply transforms, handle events, and animate with method chaining.
  • Works anywhere: Use in themes, custom modules, or inline behaviors for dashboards, icons, maps, charts, and micro-interactions.

Post-Installation

No configuration page is required. After enabling the module, the SVG.js library is available globally. You can attach it in a theme or module and write SVG.js code in your JS files. The module will use a local library if present; otherwise it loads from a CDN automatically. :contentReference[oaicite:0]{index=0}


Example: attach the library in a module

// mymodule.module
function mymodule_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = 'svgjs/svgjs.js';
}


Example: use in a Drupal behavior

(function (Drupal, once) {
  Drupal.behaviors.exampleSvg = {
    attach: function (context) {
      once('example-svg', '.svg-target', context).forEach(function (el) {
        var draw = SVG().addTo(el).size(300, 300);
        draw.rect(100, 100).fill('#f06').animate(800).move(150, 150);
      });
    }
  };
})(Drupal, once);

Additional Requirements

  • Drupal: Drupal 8.8+ (including 9/10/11). :contentReference[oaicite:1]{index=1}
  • Library: SVG.js (auto-loaded from CDN by default; optional local install at /libraries/svgjs/, e.g., /libraries/svgjs/dist/svg.min.js). :contentReference[oaicite:2]{index=2}
  • SVG asset modules (e.g., “SVG image”, “SVG Formatter”): manage/upload SVG files while this module handles client-side manipulation/animation.

Similar projects

Modules that enable SVG files or responsive images focus on rendering uploaded SVGs. This project is different: it exposes the SVG.js runtime API so you can script and animate SVG elements directly in the browser.

Supporting this Module

If you’d like to support development (sponsorships, bug bounties, feature requests), add your Patreon/OpenCollective links here.

Community Documentation

Activity

Total releases
2
First release
Sep 2025
Latest release
10 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
1.0.0-alpha1 Pre-release Sep 9, 2025
1.0.x-dev Dev Sep 9, 2025