GitHub

Copy Button

One-click clipboard copy with customizable labels and feedback duration.

<rhx-copy-button>

Examples

Copy Static Value

dotnet add package htmxRazor

Copy from Element

npm install htmxRazor-client

Custom Labels

https://example.com

Long Feedback Duration

sk-1234567890abcdef

Disabled

No copying allowed

Properties

Property Type Default Description
rhx-value string - Static text to copy to clipboard
rhx-from string - CSS selector of element whose text content to copy
rhx-copy-label string Copy Button label before copy
rhx-success-label string Copied! Button label after successful copy
rhx-feedback-duration int 2000 Milliseconds to show success label
rhx-disabled bool false Whether the button is disabled

Accessibility

  • Renders a native <button> element with aria-label describing the copy action.
  • A live region announces the copy success to screen readers.
  • Disabled state sets aria-disabled="true" and prevents interaction.
  • Focus is fully keyboard-accessible with visible focus ring.