Skip to main content Red Hat Design System logo Contribute on Github v2.0.0 Home
About About the design systemHow we buildRoadmap
Get started OverviewDesignersDevelopers
Foundations OverviewColorGridPersonalization patternsSpacingTypography
Tokens Overview Global colorBox shadowTypographyBorderOpacitySpaceLengthIconBreakpointsMedia queries
Elements All elements Accordion Alert Audio player Avatar Back to top Badge Blockquote Breadcrumb Button Call to action Card Code block Dialog Footer Health index Icon Navigation (primary)Planned Navigation (secondary) Pagination PopoverPlanned Progress stepsPlanned Site status Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed
Patterns All patternsAnnouncementCardDisclosureFilterFormLinkLink with iconLogo wallSearch barSkip navigationSticky bannerSticky cardTabsTileVideo thumbnail
Accessibility FundamentalsContentDesignDevelopmentContributorsQa and testingAssistive technologiesResources
Design/code status Release notes Get support

Code block

Overview Style Guidelines Code Demos Accessibility
  1. Style
  2. Theme
  3. Space
  4. Interaction states
  1. Style
  2. Theme
  3. Space
  4. Interaction states

Style

A code block displays read-only text with code formatting within a light gray container.

Anatomy

Image of code block anatomy showing two annotations
  1. Code text
  2. Container

Theme

A code block is available in both light and dark themes.

Light theme

Image of light theme code block

Dark theme

Image of dark theme code block

Configuration

Code block text is always horizontally and vertically centered.

Image of a code block showing alignment and border radius specs

Space

Container spacing reduces as breakpoints get smaller.

Image of a code block spacing for all breakpoints
Example Token Description
16 --rh-space-lg 16px spacer
24 --rh-space-xl 24px spacer

Interaction states

A code block includes only text and is not interactive right now.

© 2021-2024 Red Hat, Inc. Deploys by Netlify