Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

SVG.js

No security coverage Under active development

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

Ask your assistant about SVG.js

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Sep 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.0.0-alpha1 Pre-release 8–11 Sep 9, 2025
1.0.x-dev Dev 8–11 Sep 9, 2025