Skip to main content Home
About About the Design SystemRoadmap
Get started OverviewDesignersDevelopers
Foundations OverviewColorGridIconographyInteractionsSpacingTypography
Tokens Overview Global colorbox shadowTypographyborderopacityspacelengthIconBreakpointsMedia Queries
Elements All elements Accordion Alert Announcement Audio player Avatar Back to top Badge Blockquote Breadcrumb Button Card Chip Code block Call to action Dialog Disclosure Footer Health index Icon Jump links Navigation (primary) Navigation (secondary) Pagination PopoverPlanned Progress stepsPlanned Site status Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed
Theming OverviewColor PalettesCustomizingDevelopers
Patterns All PatternsCardTabsFilterFormLink with iconLogo wallSearch barSticky bannerSticky cardTile
Personalization All Personalization PatternsAnnouncement
Accessibility FundamentalsAccessibility toolsAssistive technologiesCI/CDContentContributorsDesignDevelopmentManual testingResourcesScreen readers
Design/code status Release notes Get support

Code block

OverviewStyleGuidelinesCodeAccessibilityDemos
Code BlockActions I18nActionsBelow The FoldCallout BadgesCallout PrerenderedClient Side HighlightingColor ContextPrerendered Prism HighlightingResizableSizesCode BlockActions I18nActionsBelow The FoldCallout BadgesCallout PrerenderedClient Side HighlightingColor ContextPrerendered Prism HighlightingResizableSizes

Code Block

import '@rhds/elements/rh-code-block/rh-code-block.js';
<rh-code-block>
<script type="text/html"><!DOCTYPE html>
<title>Title</title>
<style>body {width: 500px;}</style>
<script type="application/javascript">
  function $init() {return true;}
<</script><script type="text/html">/script>
<body>
  <p checked class="title" id="title">Title</p>
  <!-- here goes the rest of the page -->
</body></script>
</rh-code-block>

Actions I18n

import '@rhds/elements/rh-button/rh-button.js';
import '@rhds/elements/rh-code-block/rh-code-block.js';
import '@rhds/elements/rh-tooltip/rh-tooltip.js';
rh-code-block {
  margin-block-end: var(--rh-space-lg, 16px);
}
<rh-code-block actions="wrap copy">
  <span slot="action-label-copy">העתק</span>
  <span slot="action-label-copy" hidden="" data-code-block-state="active">הועתק!</span>
  <span slot="action-label-wrap">לעבור לגלישת שורות</span>
  <span slot="action-label-wrap" hidden="" data-code-block-state="active">לעבור להצפת שורות</span>
<script type="text/css">#content {
  display: block;
  background-color: var(--rh-color-surface-lighter, #f2f2f2);
  border: var(--rh-border-width-sm, 1px) solid var(--rh-color-border-subtle-on-light, #c7c7c7);
  border-block-start-width: var( --rh-code-block-border-block-start-width, var(--rh-border-width-sm, 1px));
  font-family: var(--rh-font-family-code, RedHatMono, "Red Hat Mono", "Courier New", Courier, monospace);
  color: var(--rh-color-text-primary-on-light, #151515);
  padding: var(--rh-space-xl, 24px);
  height: calc(100% - 2 * var(--rh-space-xl, 24px));
  border-radius: var(--rh-border-radius-default, 3px);
  max-width: 1000px;
  max-height: 640px;
  overflow-y: auto;
}</script>
</rh-code-block>

Actions

import '@rhds/elements/rh-button/rh-button.js';
import '@rhds/elements/rh-code-block/rh-code-block.js';
rh-code-block {
  margin-block-end: var(--rh-space-lg, 16px);
}
<rh-code-block actions="wrap copy">
<script type="text/css">#content {
  display: block;
  background-color: var(--rh-color-surface-lighter, #f2f2f2);
  border: var(--rh-border-width-sm, 1px) solid var(--rh-color-border-subtle-on-light, #c7c7c7);
  border-block-start-width: var( --rh-code-block-border-block-start-width, var(--rh-border-width-sm, 1px));
  font-family: var(--rh-font-family-code, RedHatMono, "Red Hat Mono", "Courier New", Courier, monospace);
  color: var(--rh-color-text-primary-on-light, #151515);
  padding: var(--rh-space-xl, 24px);
  height: calc(100% - 2 * var(--rh-space-xl, 24px));
  border-radius: var(--rh-border-radius-default, 3px);
  max-width: 1000px;
  max-height: 640px;
  overflow-y: auto;
}</script>
</rh-code-block>

Below The Fold

import '@rhds/elements/rh-code-block/rh-code-block.js';
import { RhAlert } from '@rhds/elements/rh-alert/rh-alert.js'
import { html } from 'lit';
RhAlert.toast({
  persistent: true,
  state: 'info',
  message: html`
    <dl>
      <dt>1st code block:</dt>
      <dd><em>Pending</em></dd>
      <dt>2nd code block:</dt>
      <dd><em>Pending</em></dd>
    </dl>
  `,
});

const [fst, snd] = document.querySelectorAll('rh-code-block');
const [fstP, sndP] = document.querySelectorAll('rh-alert dd em');

addEventListener('scroll', function() {
  fstP.textContent = fst.shadowRoot.querySelectorAll('#line-numbers li').length ? 'Computed' : 'Pending'
  sndP.textContent = snd.shadowRoot.querySelectorAll('#line-numbers li').length ? 'Computed' : 'Pending'
}, { passive: true });
.tall-as-screen {
  padding: var(--rh-length-lg);
  min-height: calc(100vh + 500px);
}
rh-alert dl {
  display: grid;
  font-family: var(--rh-font-family-code);
  grid-template-columns: auto auto;
  gap: var(--rh-space-md);
}
<section class="tall-as-screen">
  <p>Expect line numbers to not be calculated until just before code block scrolls into view</p>
  <p>Expect line numbers to appear without flash when scrolling down to view codeblock</p>
  <p><strong>Scroll down to view code block</strong></p>
</section>

<rh-code-block>
<script type="text/html"><!DOCTYPE html>
<title>Title</title>
<style>body {width: 500px;}</style>
<script type="application/javascript">
  function $init() {return true;}
<</script><script type="text/html">/script>
<body>
  <p checked class="title" id="title">Title</p>
  <!-- here goes the rest of the page -->
</body></script>
</rh-code-block>

<section class="tall-as-screen">
  <p>Expect only the first code block to have computed line numbers</p>
  <p>Expect second block's line numbers to compute only just before it scrolls into view</p>
  <p><strong>Scroll down to view code block</strong></p>
</section>

<rh-code-block>
<script type="text/html"><!DOCTYPE html>
<title>Title</title>
<style>body {width: 500px;}</style>
<script type="application/javascript">
  function $init() {return true;}
<</script><script type="text/html">/script>
<body>
  <p checked class="title" id="title">Title</p>
  <!-- here goes the rest of the page -->
</body></script>
</rh-code-block>

Callout Badges

import '@rhds/elements/rh-code-block/rh-code-block.js';
import '@rhds/elements/rh-badge/rh-badge.js';
<rh-code-block>
  <script type="text/html"><p>Script tags in HTML must be escaped</p></script>
  <rh-badge state="info">1</rh-badge>
  <script type="text/html">
<p>other tags do not need to be escaped</p>
<marquee>Callouts can be placed </script><rh-badge state="info">2</rh-badge><script type="text/html">inline</marquee>
</script>
  <dl slot="legend">
    <dt><rh-badge state="info">1</rh-badge></dt>
    <dd>Postfix callout</dd>
    <dt><rh-badge state="info">2</rh-badge></dt>
    <dd>Inline callout</dd>
  </dl>
</rh-code-block>

<link rel="stylesheet" href="../rh-code-block-lightdom.css">

Callout Prerendered

import '@rhds/elements/rh-code-block/rh-code-block.js';
import '@rhds/elements/rh-badge/rh-badge.js';
<rh-code-block highlighting="prerendered" actions="copy wrap">
  <pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam eleifend elit sed est egestas, a sollicitudin mauris
tincidunt. Pellentesque vel dapibus risus. Nullam aliquam</code></pre><rh-badge state="info">1</rh-badge><pre class="language-html"><code class="language-html">
felis orci, eget cursus mi lacinia quis. Vivamus at felis sem.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>rh-cta</span> <span class="token attr-name">slot</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>footer<span class="token punctuation">"</span></span> <span class="token attr-name">priority</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>#<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>Call to action<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>rh-cta</span><span class="token punctuation">&gt;</span></span></code></pre>
</rh-code-block>

Client Side Highlighting

import '@rhds/elements/lib/elements/rh-context-demo/rh-context-demo.js';
import '@rhds/elements/rh-code-block/rh-code-block.js';
rh-context-demo::part(demo) {
  display: grid;
  gap: var(--rh-space-sm, 6px);
}
<rh-context-demo>
  <rh-code-block dedent="" language="html" highlighting="client">
    <script type="text/html">
      <!DOCTYPE html>
      <html lang="en">
        <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Cards Galore!</title>
        </head>
        <body>
<main>
  <rh-card>
    <h2 slot="header">Card</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
       Nullam eleifend elit sed est egestas, a sollicitudin mauris
       tincidunt. Pellentesque vel dapibus risus. Nullam aliquam
       felis orci, eget cursus mi lacinia quis. Vivamus at felis sem.</p>
    <rh-cta slot="footer" priority="primary">
      <a href="#">Call to action</a>
    </rh-cta>
  </rh-card>
</main>
        </body>
      </html>
    </script>
  </rh-code-block>

  <rh-code-block dedent="" language="css" highlighting="client">
    <script type="text/css">
      rh-card.avatar-card {
        width: 360px;
        &::part(body) {
margin-block-start: var(--rh-space-lg, 16px);
        }

        & p {
margin-block-start: 0;
        }

        & h4 {
font-weight: var(--rh-font-weight-heading-regular, 300);
font-size: var(--rh-font-size-body-text-md, 1rem);
font-family: var(--rh-font-family-body-text);
line-height: var(--rh-line-height-body-text, 1.5);
        }
      }
    </script>
  </rh-code-block>

  <rh-code-block dedent="" language="yaml" highlighting="client">
    <script type="text/yaml">
      extends:
        - stylelint-config-standard
        - '@stylistic/stylelint-config'

      plugins:
        - ./node_modules/@rhds/tokens/plugins/stylelint.js
        - '@stylistic/stylelint-plugin'

      rules:
        rhds/token-values: true
        rhds/no-unknown-token-name:
- true
- allowed:
  - --rh-icon-size
    </script>
  </rh-code-block>
</rh-context-demo>

Color Context

import '@rhds/elements/rh-code-block/rh-code-block.js';
import '@rhds/elements/lib/elements/rh-context-demo/rh-context-demo.js';
<rh-context-demo>

<rh-code-block actions="wrap copy">
  <span slot="action-label-copy">Copy to Clipboard</span>
  <span slot="action-label-copy" hidden="" data-code-block-state="active">Copied!</span>
  <span slot="action-label-wrap">Toggle word wrap</span>
  <span slot="action-label-wrap" hidden="" data-code-block-state="active">Toggle overflow</span>
  <script type="text/text">Error: Error creating network Load Balancer: AccessDenied: User: arn:aws:sts::970xxxxxxxxx:assumed-role/ManagedOpenShift-Installer-Role/163xxxxxxxxxxxxxxxx is not authorized to perform: iam:CreateServiceLinkedRole on resource: arn:aws:iam::970xxxxxxxxx:role/aws-service-role/elasticloadbalancing.amazonaws.com/ AWSServiceRoleForElasticLoadBalancing
Error: Error creating network Load Balancer: AccessDenied: User: arn:aws:sts::970xxxxxxxxx:assumed-role/ManagedOpenShift-Installer-Role/163xxxxxxxxxxxxxxxx is not authorized to perform: iam:CreateServiceLinkedRole on resource: arn:aws:iam::970xxxxxxxxx:role/aws-service-role/elasticloadbalancing.amazonaws.com/ AWSServiceRoleForElasticLoadBalancing
Error: Error creating network Load Balancer: AccessDenied: User: arn:aws:sts::970xxxxxxxxx:assumed-role/ManagedOpenShift-Installer-Role/163xxxxxxxxxxxxxxxx is not authorized to perform: iam:CreateServiceLinkedRole on resource: arn:aws:iam::970xxxxxxxxx:role/aws-service-role/elasticloadbalancing.amazonaws.com/ AWSServiceRoleForElasticLoadBalancing
Error: Error creating network Load Balancer: AccessDenied: User: arn:aws:sts::970xxxxxxxxx:assumed-role/ManagedOpenShift-Installer-Role/163xxxxxxxxxxxxxxxx is not authorized to perform: iam:CreateServiceLinkedRole on resource: arn:aws:iam::970xxxxxxxxx:role/aws-service-role/elasticloadbalancing.amazonaws.com/ AWSServiceRoleForElasticLoadBalancing
Error: Error creating network Load Balancer: AccessDenied: User: arn:aws:sts::970xxxxxxxxx:assumed-role/ManagedOpenShift-Installer-Role/163xxxxxxxxxxxxxxxx is not authorized to perform: iam:CreateServiceLinkedRole on resource: arn:aws:iam::970xxxxxxxxx:role/aws-service-role/elasticloadbalancing.amazonaws.com/ AWSServiceRoleForElasticLoadBalancing
Error: Error creating network Load Balancer: AccessDenied: User: arn:aws:sts::970xxxxxxxxx:assumed-role/ManagedOpenShift-Installer-Role/163xxxxxxxxxxxxxxxx is not authorized to perform: iam:CreateServiceLinkedRole on resource: arn:aws:iam::970xxxxxxxxx:role/aws-service-role/elasticloadbalancing.amazonaws.com/ AWSServiceRoleForElasticLoadBalancing</script>

</rh-code-block>

</rh-context-demo>

Prerendered Prism Highlighting

import '@rhds/elements/lib/elements/rh-context-demo/rh-context-demo.js';
import '@rhds/elements/rh-code-block/rh-code-block.js';
rh-context-demo::part(demo) {
  display: grid;
  gap: var(--rh-space-sm, 6px);
}
<rh-context-demo>
  <rh-code-block highlighting="prerendered" actions="copy wrap">
  <span slot="action-label-copy">Copy to Clipboard</span>
  <span slot="action-label-copy" hidden="" data-code-block-state="active">Copied!</span>
  <span slot="action-label-wrap">Toggle word wrap</span>
  <span slot="action-label-wrap" hidden="" data-code-block-state="active">Toggle overflow</span>
    <pre class="language-html"><code class="language-html"><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>en<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>utf-8<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>viewport<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>width=device-width<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">&gt;</span></span>Cards Galore!<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>main</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>rh-card</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span> <span class="token attr-name">slot</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>header<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>Card<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 Nullam eleifend elit sed est egestas, a sollicitudin mauris
 tincidunt. Pellentesque vel dapibus risus. Nullam aliquam
 felis orci, eget cursus mi lacinia quis. Vivamus at felis sem.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>rh-cta</span> <span class="token attr-name">slot</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>footer<span class="token punctuation">"</span></span> <span class="token attr-name">priority</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>#<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>Call to action<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>rh-cta</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>rh-card</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>main</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span></code></pre>
  </rh-code-block>

  <rh-code-block highlighting="prerendered" actions="copy wrap">
  <span slot="action-label-copy">Copy to Clipboard</span>
  <span slot="action-label-copy" hidden="" data-code-block-state="active">Copied!</span>
  <span slot="action-label-wrap">Toggle word wrap</span>
  <span slot="action-label-wrap" hidden="" data-code-block-state="active">Toggle overflow</span>
    <pre class="language-css"><code class="language-css"><span class="token selector">rh-card.avatar-card</span> <span class="token punctuation">{</span>
  <span class="token property">width</span><span class="token punctuation">:</span> 360px<span class="token punctuation">;</span>
  <span class="token selector">&amp;::part(body)</span> <span class="token punctuation">{</span>
    <span class="token property">margin-block-start</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--rh-space-lg<span class="token punctuation">,</span> 16px<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token selector">&amp; p</span> <span class="token punctuation">{</span>
    <span class="token property">margin-block-start</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token selector">&amp; h4</span> <span class="token punctuation">{</span>
    <span class="token property">font-weight</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--rh-font-weight-heading-regular<span class="token punctuation">,</span> 300<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token property">font-size</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--rh-font-size-body-text-md<span class="token punctuation">,</span> 1rem<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token property">font-family</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--rh-font-family-body-text<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token property">line-height</span><span class="token punctuation">:</span> <span class="token function">var</span><span class="token punctuation">(</span>--rh-line-height-body-text<span class="token punctuation">,</span> 1.5<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
  </rh-code-block>

  <rh-code-block highlighting="prerendered" actions="copy wrap">
  <span slot="action-label-copy">Copy to Clipboard</span>
  <span slot="action-label-copy" hidden="" data-code-block-state="active">Copied!</span>
  <span slot="action-label-wrap">Toggle word wrap</span>
  <span slot="action-label-wrap" hidden="" data-code-block-state="active">Toggle overflow</span>
    <pre class="language-yaml"><code class="language-yaml"><span class="token key atrule">extends</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> stylelint<span class="token punctuation">-</span>config<span class="token punctuation">-</span>standard
  <span class="token punctuation">-</span> <span class="token string">'@stylistic/stylelint-config'</span>

<span class="token key atrule">plugins</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> ./node_modules/@rhds/tokens/plugins/stylelint.js
  <span class="token punctuation">-</span> <span class="token string">'@stylistic/stylelint-plugin'</span>

<span class="token key atrule">rules</span><span class="token punctuation">:</span>
  <span class="token key atrule">rhds/token-values</span><span class="token punctuation">:</span> <span class="token boolean important">true</span>
  <span class="token key atrule">rhds/no-unknown-token-name</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> <span class="token boolean important">true</span>
    <span class="token punctuation">-</span> <span class="token key atrule">allowed</span><span class="token punctuation">:</span>
      <span class="token punctuation">-</span> <span class="token punctuation">-</span><span class="token punctuation">-</span>rh<span class="token punctuation">-</span>icon<span class="token punctuation">-</span>size</code></pre>
  </rh-code-block>
</rh-context-demo>

Resizable

import '@rhds/elements/rh-code-block/rh-code-block.js';
<rh-code-block resizable="">
  <script type="text/text">Error: Error creating network Load Balancer: AccessDenied: User: arn:aws:sts::970xxxxxxxxx:assumed-role/ManagedOpenShift-Installer-Role/163xxxxxxxxxxxxxxxx is not authorized to perform: iam:CreateServiceLinkedRole on resource: arn:aws:iam::970xxxxxxxxx:role/aws-service-role/elasticloadbalancing.amazonaws.com/AWSServiceRoleForElasticLoadBalancing</script>
</rh-code-block>

Sizes

import '@rhds/elements/rh-code-block/rh-code-block.js';
rh-code-block {
  margin-block-end: var(--rh-space-lg, 16px);
}
<hgroup>
  <h2>Sizes</h2>
  <h3>Standard</h3>
</hgroup>

<rh-code-block>
  <script type="application/shell">oc apply -f ostoy-microservice-deployment.yaml</script>
</rh-code-block>

<rh-code-block>
  <script type="text/sample">$ podman login -u flozanorht quay.io
Password:
Login Succeeded!
$ skopeo copy docker://registry.access.redhat.com/ubi8/ubi:8.0-122 \
docker://quay.io/flozanorht/ubi:8
...
Writing manifest to image destination
Storing signatures</script>
</rh-code-block>

<h3>Compact</h3>

<rh-code-block compact="">
  <script type="application/shell">oc apply -f ostoy-microservice-deployment.yaml</script>
</rh-code-block>

<rh-code-block compact="">
  <script type="text/sample">$ podman login -u flozanorht quay.io
Password:
Login Succeeded!
$ skopeo copy docker://registry.access.redhat.com/ubi8/ubi:8.0-122 \
docker://quay.io/flozanorht/ubi:8
...
Writing manifest to image destination
Storing signatures</script>
</rh-code-block>

<h3>No fixed width</h3>

<rh-code-block style="width: max-content;">
  <script type="application/shell">oc apply -f ostoy-microservice-deployment.yaml</script>
</rh-code-block>

<rh-code-block style="width: max-content;">
  <script type="text/text">$ podman login -u flozanorht quay.io
Password:
Login Succeeded!
$ skopeo copy docker://registry.access.redhat.com/ubi8/ubi:8.0-122 \
docker://quay.io/flozanorht/ubi:8
...
Writing manifest to image destination
Storing signatures</script>
</rh-code-block>

<h3>Responsive sizes</h3>

<div style="max-width: 564px">
<rh-code-block>
  <rh-code-action slot="actions" action="copy">Copy to Clipboard</rh-code-action>
  <rh-code-action slot="actions" action="wrap">
    Toggle
    <span slot="inactive">line wrap</span>
    <span slot="active">overflow</span>
  </rh-code-action>
  <script type="text/sample">$ podman login -u flozanorht quay.io
Password:
Login Succeeded!
$ skopeo copy docker://registry.access.redhat.com/ubi8/ubi:8.0-122 \
docker://quay.io/flozanorht/ubi:8
...
Writing manifest to image destination
Storing signatures</script>
</rh-code-block>
</div>

<div style="max-width: 328px">
<rh-code-block>
  <rh-code-action slot="actions" action="copy">Copy to Clipboard</rh-code-action>
  <rh-code-action slot="actions" action="wrap">
    Toggle
    <span slot="inactive">line wrap</span>
    <span slot="active">overflow</span>
  </rh-code-action>
  <script type="text/sample">$ podman login -u flozanorht quay.io
Password:
Login Succeeded!
$ skopeo copy docker://registry.access.redhat.com/ubi8/ubi:8.0-122 \
docker://quay.io/flozanorht/ubi:8
...
Writing manifest to image destination
Storing signatures</script>
</rh-code-block>
</div>
© 2021-2025 Red Hat, Inc. Deploys by Netlify