| 1 |
--- |
| 2 |
id: Code block |
| 3 |
section: components |
| 4 |
cssPrefix: pf-v6-c-code-block |
| 5 |
propComponents: ['CodeBlock', 'CodeBlockAction', 'CodeBlockCode'] |
| 6 |
--- |
| 7 |
|
| 8 |
import { Fragment, useState } from 'react'; |
| 9 |
import RhUiCopyFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-copy-fill-icon'; |
| 10 |
import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon'; |
| 11 |
|
| 12 |
**Important note:** to format code exactly as it is, you should use String.raw\`your code here\`. |
| 13 |
|
| 14 |
Using **String.raw\`\`** will keep all the special characters like `\n` or `\t`. |
| 15 |
|
| 16 |
## Examples |
| 17 |
|
| 18 |
### Basic |
| 19 |
|
| 20 |
```ts file="./CodeBlockBasic.tsx" |
| 21 |
|
| 22 |
``` |
| 23 |
|
| 24 |
### Expandable |
| 25 |
|
| 26 |
```ts file="./CodeBlockExpandable.tsx" |
| 27 |
|
| 28 |
``` |