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

Code block

Overview Style Guidelines Code Demos Accessibility

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