1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
|
---
id: Clipboard copy
section: components
cssPrefix: pf-v6-c-clipboard-copy
---## Examples
### Basic
```html
<div class="pf-v6-c-clipboard-copy">
<div class="pf-v6-c-clipboard-copy__group">
<span class="pf-v6-c-form-control">
<input
type="text"
value="This is editable"
id="basic-editable-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
id="basic-editable-copy-button"
type="button"
aria-label="Copy to clipboard basic editable example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
</div>
<br />
<div class="pf-v6-c-clipboard-copy">
<div class="pf-v6-c-clipboard-copy__group">
<span class="pf-v6-c-form-control pf-m-readonly">
<input
readonly
type="text"
value="This is read-only"
id="basic-readonly-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
id="basic-readonly-copy-button"
type="button"
aria-label="Copy to clipboard basic read-only example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
</div>
```
### Expandable
```html
<h4>Editable</h4>
<div class="pf-v6-c-clipboard-copy">
<div class="pf-v6-c-clipboard-copy__group">
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-expanded="false"
id="expandable-not-expanded-editable-toggle"
aria-label="Toggle unexpanded editable example"
aria-controls="expandable-not-expanded-editable-content"
>
<span class="pf-v6-c-button__icon">
<div class="pf-v6-c-clipboard-copy__toggle-icon">
<i class="fas fa-angle-right" aria-hidden="true"></i>
</div>
</span>
</button>
<span class="pf-v6-c-form-control">
<input
type="text"
value="This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion."
id="expandable-not-expanded-editable-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-label="Copy to clipboard unexpanded editable example"
id="expandable-not-expanded-editable-copy-button"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
<div
class="pf-v6-c-clipboard-copy__expandable-content"
hidden
id="expandable-not-expanded-editable-content"
>This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion.</div>
</div>
<br />
<div class="pf-v6-c-clipboard-copy pf-m-expanded">
<div class="pf-v6-c-clipboard-copy__group">
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-expanded="true"
id="expandable-expanded-editable-toggle"
aria-label="Toggle expanded editable example"
aria-controls="expandable-expanded-editable-content"
>
<span class="pf-v6-c-button__icon">
<div class="pf-v6-c-clipboard-copy__toggle-icon">
<i class="fas fa-angle-right" aria-hidden="true"></i>
</div>
</span>
</button>
<span class="pf-v6-c-form-control pf-m-readonly">
<input
readonly
type="text"
value="This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion."
id="expandable-expanded-editable-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-label="Copy to clipboard expanded editable example"
id="expandable-expanded-editable-copy-button"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
<div
class="pf-v6-c-clipboard-copy__expandable-content"
contenteditable="true"
id="expandable-expanded-editable-content"
>This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion.</div>
</div>
<br />
<h4>Read-only</h4>
<div class="pf-v6-c-clipboard-copy">
<div class="pf-v6-c-clipboard-copy__group">
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-expanded="false"
id="expandable-not-expanded-readonly-toggle"
aria-label="Toggle read-only unexpanded example"
aria-controls="expandable-not-expanded-readonly-content"
>
<span class="pf-v6-c-button__icon">
<div class="pf-v6-c-clipboard-copy__toggle-icon">
<i class="fas fa-angle-right" aria-hidden="true"></i>
</div>
</span>
</button>
<span class="pf-v6-c-form-control pf-m-readonly">
<input
readonly
type="text"
value="This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion."
id="expandable-not-expanded-readonly-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-label="Copy to clipboard read-only collapsed example"
id="expandable-not-expanded-readonly-copy-button"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
<div
class="pf-v6-c-clipboard-copy__expandable-content"
hidden
id="expandable-not-expanded-readonly-content"
>This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion.</div>
</div>
<br />
<div class="pf-v6-c-clipboard-copy pf-m-expanded">
<div class="pf-v6-c-clipboard-copy__group">
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-expanded="true"
id="expandable-expanded-readonly-toggle"
aria-label="Toggle read-only expanded example"
aria-controls="expandable-expanded-readonly-content"
>
<span class="pf-v6-c-button__icon">
<div class="pf-v6-c-clipboard-copy__toggle-icon">
<i class="fas fa-angle-right" aria-hidden="true"></i>
</div>
</span>
</button>
<span class="pf-v6-c-form-control pf-m-readonly">
<input
readonly
type="text"
value="This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion."
id="expandable-expanded-readonly-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-label="Copy to clipboard read-only expanded example"
id="expandable-expanded-readonly-copy-button"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
<div
class="pf-v6-c-clipboard-copy__expandable-content"
id="expandable-expanded-readonly-content"
>This is an editable version of the copy to clipboard component that has an expandable section. Got a lot of text here, need to see all of it? Click that arrow on the left side and check out the resulting expansion.</div>
</div>
<br />
<h4>Code</h4>
<div class="pf-v6-c-clipboard-copy">
<div class="pf-v6-c-clipboard-copy__group">
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-expanded="false"
id="expandable-not-expanded-code-toggle"
aria-label="Toggle code unexpanded example"
aria-controls="expandable-not-expanded-code-content"
>
<span class="pf-v6-c-button__icon">
<div class="pf-v6-c-clipboard-copy__toggle-icon">
<i class="fas fa-angle-right" aria-hidden="true"></i>
</div>
</span>
</button>
<span class="pf-v6-c-form-control">
<input
dir="ltr"
type="text"
value="{ "menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }} "
id="expandable-not-expanded-code-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-label="Copy to clipboard code unexpanded example"
id="expandable-not-expanded-code-copy-button"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
<div
class="pf-v6-c-clipboard-copy__expandable-content"
hidden
id="expandable-not-expanded-code-content"
>
<pre dir="ltr">{ "menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
</pre>
</div>
</div>
<br />
<div class="pf-v6-c-clipboard-copy pf-m-expanded">
<div class="pf-v6-c-clipboard-copy__group">
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-expanded="true"
id="expandable-expanded-code-toggle"
aria-label="Toggle code expanded example"
aria-controls="expandable-expanded-code-content"
>
<span class="pf-v6-c-button__icon">
<div class="pf-v6-c-clipboard-copy__toggle-icon">
<i class="fas fa-angle-right" aria-hidden="true"></i>
</div>
</span>
</button>
<span class="pf-v6-c-form-control pf-m-readonly">
<input
readonly
dir="ltr"
type="text"
value="{ "menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }} "
id="expandable-expanded-code-text-input"
aria-label="Copyable input"
/>
</span>
<button
class="pf-v6-c-button pf-m-control"
type="button"
aria-label="Copy to clipboard code expanded example"
id="expandable-expanded-code-copy-button"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</div>
<div
class="pf-v6-c-clipboard-copy__expandable-content"
contenteditable="true"
id="expandable-expanded-code-content"
>
<pre dir="ltr">{ "menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
</pre>
</div>
</div>
```
### Inline compact
```html
<div class="pf-v6-c-clipboard-copy pf-m-inline">
<span class="pf-v6-c-clipboard-copy__text">2.3.4-2-redhat</span>
<span class="pf-v6-c-clipboard-copy__actions">
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Copy to clipboard inline compact example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
</span>
</div>
```
### Inline compact code
```html
<div class="pf-v6-c-clipboard-copy pf-m-inline">
<code class="pf-v6-c-clipboard-copy__text pf-m-code">2.3.4-2-redhat</code>
<span class="pf-v6-c-clipboard-copy__actions">
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Copy to clipboard inline compact code example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
</span>
</div>
```
### Inline compact with additional action
```html
<div class="pf-v6-c-clipboard-copy pf-m-inline">
<span class="pf-v6-c-clipboard-copy__text">2.3.4-2-redhat</span>
<span class="pf-v6-c-clipboard-copy__actions">
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Copy to clipboard inline compact with additional action example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Run in web terminal"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
</span>
</div>
```
### Inline compact in sentence
```html
<h4>
<strong>Basic</strong>
</h4>Lorem ipsum
<div class="pf-v6-c-clipboard-copy pf-m-inline">
<span class="pf-v6-c-clipboard-copy__text">2.3.4-2-redhat</span>
<span class="pf-v6-c-clipboard-copy__actions">
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Copy to clipboard basic inline compact example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
</span>
</div>
dolor sit amet.
<br />
<br />
<h4>
<strong>Long copy string</strong>
</h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<div class="pf-v6-c-clipboard-copy pf-m-inline">
<span
class="pf-v6-c-clipboard-copy__text"
>https://app.openshift.io/path/sub-path/sub-sub-path/?runtime=quarkus/12345678901234567890/abcdefghijklmnopqrstuvwxyz1234567890</span>
<span class="pf-v6-c-clipboard-copy__actions">
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Copy to clipboard long inline compact example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
</span>
</div> Mauris luctus, libero nec dapibus ultricies, urna purus pretium mauris, ullamcorper pharetra lacus nibh vitae enim.
<br />
<br />
<h4>
<strong>Long copy string in block</strong>
</h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<div class="pf-v6-c-clipboard-copy pf-m-inline pf-m-block">
<span
class="pf-v6-c-clipboard-copy__text"
>https://app.openshift.io/path/sub-path/sub-sub-path/?runtime=quarkus/12345678901234567890/abcdefghijklmnopqrstuvwxyz1234567890</span>
<span class="pf-v6-c-clipboard-copy__actions">
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Copy to clipboard long block compact example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
</span>
</div> Mauris luctus, libero nec dapibus ultricies, urna purus pretium mauris, ullamcorper pharetra lacus nibh vitae enim.
```
### Inline compact with truncation
```html
<div class="pf-v6-c-clipboard-copy pf-m-inline pf-m-truncate">
<span class="pf-v6-c-clipboard-copy__text">
<span class="pf-v6-c-truncate" tabindex="0">
<span
class="pf-v6-c-truncate__start"
>This lengthy, copyable content will be truncated with default settings when the truncation prop is simply set to true. This is useful for quickly applying truncation without needing to worry about any other properties to set.</span>
</span>
</span>
<span class="pf-v6-c-clipboard-copy__actions">
<span class="pf-v6-c-clipboard-copy__actions-item">
<button
class="pf-v6-c-button pf-m-no-padding pf-m-plain"
type="button"
aria-label="Copy to clipboard inline compact with truncation example"
>
<span class="pf-v6-c-button__icon">
<i class="fas fa-copy" aria-hidden="true"></i>
</span>
</button>
</span>
</span>
</div>
```
## Documentation
### Accessibility
| Attribute | Applied to | Outcome |
| -- | -- | -- |
| `aria-label="Copy to clipboard"`, `aria-label="Show content"` | `.pf-v6-c-button.pf-m-control` | Provides an accessible name for the button when an icon is used instead of text. **Required when an icon is used with no supporting text.** |
| `aria-label="[input label text]"` | `.pf-v6-c-form-control` | Provides an accessible label for the input. Provide a label that describes the contents in the input. **Required** |
| `aria-hidden="true"` | `<i>` | Hides the icon from assistive technologies. |
| `aria-controls="[id of expandable element]"` | `.pf-v6-c-button.pf-m-control` | Identifies the element controlled by the toggle button. **Required** |
| `hidden` | `.pf-v6-c-clipboard-copy__expandable-content` | Indicates that the expandable content is hidden so that it isn't visible in the UI and isn't accessed by assistive technologies. |
| `aria-labelledby="[id of button] [id of input label]"` | `.pf-v6-c-button.pf-m-control` | Provides an accessible name that is unique and communicates context of the button. Required when more than one ClipboardCopy component exists on the page. **Important:** If the label is defined on the `<input>` using `aria-label`, then use the `id` of the `<input>`. If the label is defined in a `<label>`, then use the `id` of the `<label>`. **Alternatively** this attribute can be ignored if the text input label is defined as part of the value in `aria-label`. |
### Usage
| Class | Applied to | Outcome |
| -- | -- | -- |
| `.pf-v6-c-clipboard-copy` | `<div>` | Initiates a clipboard copy component. **Required** |
| `.pf-v6-c-clipboard-copy__group` | `<div>` | Initiates a wrapper for the clipboard copy group. **Required** |
| `.pf-v6-c-clipboard-copy__toggle-icon` | `<div>` | Initiates a toggle button icon. |
| `.pf-v6-c-clipboard-copy__expandable-content` | `<div>` | Initiates an expandable element. |
| `.pf-v6-c-clipboard-copy__text` | `<span>` | Initiates the inline copy clipboard text element. **Required** |
| `.pf-v6-c-clipboard-copy__actions` | `<span>` | Initiates the inline copy clipboard actions element. **Required** |
| `.pf-v6-c-clipboard-copy__actions-item` | `<span>` | Initiates the inline copy clipboard actions item element. **Required** |
| `.pf-m-inline` | `.pf-v6-c-clipboard-copy` | Modifies the clipboard copy component for inline styles. |
| `.pf-m-block` | `.pf-v6-c-clipboard-copy.pf-m-inline` | Modifies the inline copy clipboard component to have block formatting. |
| `.pf-m-truncate` | `.pf-v6-c-clipboard-copy.pf-m-truncate` | Modifies the inline copy clipboard component for use with text used in trucate component. |
| `.pf-m-expanded` | `.pf-v6-c-clipboard-copy` | Modifies the clipboard copy component for the expanded state. |
| `.pf-m-expanded` | `.pf-v6-c-button.pf-m-control` | Modifies the control toggle button for the expanded state. |
| `.pf-m-code` | `code.pf-v6-c-clipboard-copy__text` | Modifies the inline copy clipboard text styles for use with the `<code>` element. |
|