Need help with ngx-clipboard?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

460 Stars 90 Forks MIT License 409 Commits 10 Opened issues


A pure angular clipboard directive

Services available


Need anything else?

Contributors list

Financial Contributors on Open Collective ngx-clipboard npm GitHub release npm

ngx-clipboard , F.K.A angular2-clipboard

From 6.0.0, there is no other JS dependency anymore. Just Angular.

It works with angular version 2.0.0 and up

To make more sense with the future versioning scheme of Angular, the directive selector is now rename to ngxClipboard


  • If you need to use it on 2.x, please use version 7.x.x.
  • If you need to use it on 4.x, please use version 8.x.x.
  • If you need to use it on 5.x, please use version 10.x.x.
  • If you need to use it on 8.x, please use version 12.x.x.
  • If you need to use it on 9.x, please use version 13.x.x.
  • If you need to use it on 10.x - 12.x, please use version 14.0.2.
  • If you need to use it on 13.x, please use version 15.x.x. (Also thanks for updating & tuning)

The code are pretty much the same, in v8.0.0 it uses InjectionToken which requires angular4 and above.


You can get it on npm.

npm install ngx-clipboard --save

Open your module file e.g

and update imports array
import { ClipboardModule } from 'ngx-clipboard';
imports: [


If you use SystemJS to load your files, you might have to update your config:

    map: {
        'ngx-clipboard': 'node_modules/ngx-clipboard'

Copy source

This library support multiple kinds of copy source.

  • Setting

You can assign the parent container to avoid focus trapper issue, #145

  • Setting an input target


  • Using
    to copy any text you dynamically created.
import { ClipboardService } from 'ngx-clipboard'


constructor(private _clipboardService: ClipboardService){ ... }

copy(text: string){ this._clipboardService.copy(text) }


  • cbOnSuccess
    callback attribute is triggered after copy was successful with
    $event: {isSuccess: true, content: string}

Or updating parameters directly like so

  • cbOnError
    callback attribute is triggered when there's failure in copying with
    $event:{isSuccess: false}

Conditionally render host

You can also use the structural directive *ngxClipboardIfSupported to conditionally render the host element


Special thanks to @surajpoddar16 for implementing this feature

Handle copy response globally

To handle copy response globally, you can subscribe to

exposed by the
export class ClipboardResponseService {
    private _clipboardService: ClipboardService,
    private _toasterService: ToasterService
  ) {

handleClipboardResponse() { this._clipboardService.copyResponse$.subscribe((res: IClipboardResponse) => { if (res.isSuccess) { this._toasterService.pop('success', undefined, res.successMessage); } }); } }

Special thanks to @surajpoddar16 for implementing this feature

Clean up temporary textarea used by this module after each copy to clipboard

This library creates a textarea element at the root of the body for its internal use. By default it only destroys it when the directive is destroyed. If you'd like it to be destroyed after each copy to clipboard, provide root level module configuration like this:

ClipboardService.configure({ cleanUpAfterCopy: true });

Special thanks to @DmitryEfimenko for implementing this feature


Build project

npm i && npm run build

To run demo code locally

npm run start


  • Your commits conform to the conventions established here


Please ask your general questions at

Shoutouts 🙏

Kudos to

Thierry Templier This project is inspired by his answer on StackOverflow.

The core function is ported from clipboard.js by @zenorocha.

This project was generated with Angular CLI version 7.

BrowserStack Logo

Big thanks to BrowserStack for letting the maintainers use their service to debug browser issues.


Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]



Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.