Live demo — this example is server-driven; run the showcase locally for the interactive version.

Clipboard copy

A field with a copy-to-clipboard button. Three layouts: standard (input + button), inline (compact in-line snippet), and expandable (single-line summary + collapsible full content).

Examples

Basic

Input + copy button; the icon flips to a check on copy.

Read only

The input cannot be edited.

Expanded

A toggle reveals the expandable panel.

Full multi-line content that becomes visible when the user clicks the toggle. Useful for long commands or configuration snippets.

Read only expanded

Read-only combined with the expandable panel.

The expandable panel content — still read-only.

Read only expanded by default

expanded=true opens the panel on load.

This panel is open on load thanks to the builder's expanded() call.

Expanded with array

Multiple lines in the panel; copy grabs all of them.

ssh-rsa AAAAB3Nza...key-one user@host
ssh-rsa AAAAB3Nza...key-two user@host
ssh-rsa AAAAB3Nza...key-three user@host

JSON object (wrap code with pre)

The panel wraps JSON in a <pre>.

{ "kind": "ConfigMap", "metadata": { "name": "app-config" }, "data": { "LOG_LEVEL": "info" } }

Inline compact

Plain inline text + copy action.

2.3.4-2-redhat

Inline compact code in sentence

Code-styled inline copy embedded in a sentence.

Run
npm install
to install dependencies.

Inline compact with additional action

A second action button follows the copy action.

oc new-app httpd-example

Inline compact with truncation

The displayed value truncates; the full text is copied.

https://app.example.com/api/v2/deployments/3f9c2a17-55de-4d1b-9d6f

Documentation

Clipboard copy props

Parameters accepted by {#include components/forms/clipboard-copy ... /}. Model mode: pass clipboardCopy=<ClipboardCopy> built in Java instead — the Java tab on each example shows the builder.

* required
Name Type Description
* id String DOM id.
* text String The value shown + copied. Kept as a String param (not a content slot) — see the Divergence note below.
readonly / expandable / inline / code / block boolean Layout modifiers. expandable shows a chevron toggle; inline uses compact in-flow rendering.
expandedText String Used with expandable=true — full multi-line content shown when expanded.

Usage

Browser support. The component uses navigator.clipboard.writeText() — supported in all modern browsers but requires HTTPS or localhost.

Pick the layout. Inline for short snippets ("run npm install"). Standard for tokens / URLs. Expandable for long config blocks where the headline alone is meaningful.

Divergence from PF React (and the rest of our library). Most of our text-bearing components migrated their text param to a content slot for parity with PF's children; clipboard-copy keeps text as a String param. The default and expandable variants put the value into <input value="…"> — an attribute that requires a primitive string. PF React's children works there only because React stringifies children when assigned to value={children}; Qute has no equivalent slot-to-string mechanism (no built-in {#capture} directive). Keeping text as a String is the only shape that works uniformly across all three variants. The inline variant could use a slot in isolation, but a split API (slot in one mode, param in two) is more confusing than a uniform param.