Copy to Clipboard

Copy to Clipboard

Overview

The copy to clipboard component allows users to quickly and easily copy content to their clipboard.

The content to be copied should be displayed in a text box with the copy icon on the right. Users may copy content to their clipboard by clicking the clipboard icon. This pattern can be used inline or as a separate block. Copy content may vary but is usually a string of characters.

Basic Example

Basic Example

Long String Inline Example

Inline Example

Long String Block Example

Block Example

Copy to Clipboard

Patterns Available:

Basic

Initial State

Initial State

  1. Copy content: The content that is to be copied is distinguished from the adjacent text by a text box.
  2. Icon: The clipboard icon (fa-clipboard) should be used to indicate that clicking the button will copy the encompassed text to the user’s clipboard.
  3. Tooltip: On hover, the tooltip reads “Copy to Clipboard.” Screenreader text will also read “Copy to Clipboard.”

Copied State

Copied State

  1. Copy content: The copy content does not change after being copied.
  2. Icon: A checkmark icon (fa-check) should be used to indicate that the encompassed text has been copied to the user’s clipboard. This icon should remain for 2-3 seconds before returning to the copy icon.
  3. Tooltip: After the copy icon has been clicked, the tooltip reads “Copied!” This tooltip should remain for 2-3 seconds before returning to the “Copy to Clipboard” text. Screenreader text will read back to the user the content they have copied. (Eg. “Copied ‘Lorem ipsum dolor sit amet.’”)

Long String Inline

If the content to be copied is longer than the desired text box length and is being used inline, users can scroll within the text box to view the entire string. If the content is very long, the block format is recommended.

Long String Inline

  1. Text Fade: Text will fade out to the right to indicate that more text is available for viewing.

Long String Block

If the content to be copied is longer than the desired text box length and is being used as a block, users can expand the text box to view the entire string.

Long String Block

  1. Caret: A caret will indicate that more text is available for viewing and allows users to hide and view the full text to be copied.
  2. Expanded View: Users can view the entire string to be copied in the expanded view of the component.

Code icon

PatternFly Core Example Not Available

There is no PatternFly-Core code available for this pattern at this time. Links to the JS framework implementations can be seen above.

Visit the Contributing to PatternFly documentation to learn how to contribute the code.