Skip to main content Red Hat Design System logo Contribute on Github

Code block

Overview Style Guidelines Code Accessibility

Overview

A code block is formatted text within a container.

Image of a code block with black code text within a light gray container

Status

What do these mean?
Figma library:
Ready
RH Elements:
Ready
WebRH:
Ready

Sample element

Demo

View a live version of this element to see how it can be customized.

<rh-code-block>
<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>

<script type="module">
import '@rhds/elements/rh-code-block/rh-code-block.js';
</script>

Full screen demo

When to use

  • When you need to highlight a block of code while maintaining the formatting

Property Status Meaning
Figma library Ready Component is available in the Figma library
RH Elements Ready Component is available in the RH Elements repo
WebRH Ready Component is available in the WebRH repo
© 2021-2024 Red Hat, Inc. Deploys by Netlify