Skip to main content

Copy button

shadow

The Copy button allows you to copy the desired content to the clipboard with one click. Supported elements are input, textarea, wje-input, wje-label and a element.

Basic usage

The sample shows a copy button in its simplest form, i.e. as a button that copies a prepared value without any additional logic around it. The tooltip is not shown automatically; enable it with the tooltip attribute.

Custom label

The tooltip is rendered only when the tooltip attribute is present. The label attribute provides an accessible label and is also used as fallback tooltip text when tooltip is present without a custom value. The label-success attribute changes the tooltip text after a successful copy.

Element

The sample copies text from a regular DOM element. It is useful when the source value is not an input but, for example, a static code or identifier.

Input

The sample copies the actual value from the classic input, so you can see a common form scenario.

WJE-Input

The sample does the same for wje-input, i.e. it links the copy button directly to the value of the WebJET input component.

The preview copies the value from the link, which is useful, for example, for share URLs or links to external resources.

When to use

Use the wje-copy-button when the user enters a value, selects options, or performs an action on a form.

When not to use

Don't just use it as a visual decorative element without interaction. In this case, give priority to the presentation components.

Accessibility

Always link the component to a description (label/aria-label) and keep keyboard control. The label attribute does not show a visual tooltip by itself; add the tooltip attribute when you want to display one.

  • Keep validation rules and error states consistent across the entire form.
  • For asynchronous operations, display the load status or disabled status.
  • For complex forms, prefer smaller sections and immediate feedback.

Attributes and properties

for

PopisNastavuje textovú hodnotu uloženú vo voľbe for.
Atribútfor
Typstring
Predvolené-

label

PopisNastavuje zobrazený alebo prístupný textový štítok.
Atribútlabel
Typstring
Predvolené-

labelSuccess

PopisNastavuje zobrazovaný text pre voľbu label-success.
Atribútlabel-success
Typstring
Predvolené-

tooltip

PopisNastavuje textovú hodnotu uloženú vo voľbe tooltip.
Atribúttooltip
Typstring
Predvolené-

value

PopisNastavuje aktuálnu hodnotu komponentu.
Atribútvalue
Typstring
Predvolené-

Events

NázovPopis
wje-copy-button:clickVyvolá sa pri kliknutí na komponent.

Methods

copy

PopisSpustí metódu copy na vykonanie logiky komponentu a aktualizáciu jeho stavu.
Signatúra(button: HTMLElement) => void

CSS shadow parts

NázovPopis
buttonŠtýluje shadow časť button.

CSS custom variables

NázovPopis
--text-colorVlastná CSS premenná, ktorá riadi text color.
--background-colorVlastná CSS premenná, ktorá riadi background color.

Slots

NázovPopis
defaultPredvolený slot pre hlavný obsah komponentu.