Ship faster with goilerplate templUI Pro

Copy Button

Button component that copies content from target elements to clipboard.

Source Tailwind CSS JavaScript

Hello, World!

Installation

templui add copybutton

Load the script once in your layout:

<head>
  @copybutton.Script()
</head>

Examples

With Input

API Reference

Required parameter
Hover for description

CopyButton

Button component that copies content from a target element to the clipboard.

Name Type Default
ID

Unique identifier for the button element.

string
-
Class

Additional CSS classes to apply to the button.

string
-
Attrs

Additional HTML attributes to apply to the button element.

templ.Attributes
-
TargetID

ID of the element to copy content from. Automatically detects whether to use .value or .textContent.

string
-