Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Clipboard.js

Security covered Maintenance fixes only 1,945 sites

This module integrates the clipboard.js library to enable non-flash based copying of text to the clipboard using the HTML5 Clipboard API. It provides field formatters for various field types and allows custom form fields to utilize clipboard.js functionality.

Overview

The Clipboard.js module provides integration with the clipboard.js library, which allows non-flash based clipboard copying using the HTML5 Clipboard API.

Usage

The module provides a field formatter for email, link, string, string_long, number and slug fields.

Available are the Clipboard.js Button, the Clipboard.js Snippet, the Clipboard.js Textarea and the well-known Clipboard.js Textfield formatter.

The Clipboard.js can be added to any supported field type field by visiting the manage display page for the entity and choosing Clipboard.js as the field formatter.

Custom form fields can also use clipboard.js using the form api or in a render
array using the theme function to display the element:

$form['clipboardjs'] = [
  '#theme' => 'clipboardjs_button',
  '#value' => 'Any copyable value.',
];

Or a full example of one of the available templates e.g., clipboardjs_button,
clipboardjs_snippet, clipboardjs_textarea or clipboardjs_textfield:

$form['clipboardjs'] = [
  '#type' => 'item',
  '#theme' => 'clipboardjs_textfield',
  '#title' => $this->t('Clipboard.js Textfield'),
  '#value' => 'Any copyable value.',
  '#label' => $this->t('Click to copy'),
  '#alert_style' => 'tooltip', // e.g., 'tooltip', 'alert' or 'none'
  '#alert_text' => $this->t('Copied!'),
];

Requirements

Installation
It is assumed you are installing Drupal through Composer using the Drupal
Composer facade. See https://www.drupal.org/docs/develop/using-composer/using-composer-to-man...

It is recommended downloading third-party libraries using composer. See https://www.drupal.org/docs/develop/using-composer/manage-dependencies#t...
Follow the instructions to set up the Asset Packagist.

composer require npm-asset/clipboard:^2.0.11

πŸ‡ΊπŸ‡¦

#StandWithUkraine
Please consider supporting Ukraine in a fight for their freedom and safety of Europe.

Logo icon by Solar Icons in CC Attribution License via SVG Repo

Drupal 8–10 · not 11

Ask your assistant about Clipboard.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
4
Tracked since
Nov 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 3
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
2.1.0-rc1 Pre-release 10–11 Jan 30, 2025
2.0.9 Stable 8–10 Jan 30, 2025
2.1.x-dev Dev 10–11 Jan 29, 2025
2.0.8 Stable 8–10 Nov 4, 2023