Skip to main contentCarbon Design System

Code snippet

Code snippets are strings or small blocks of reusable code that can be copied and inserted in a code file.


There are three different variants of code snippets to help cater to varied line length use cases—inline, single line, and multi-line.


InlineA block of text used inline with sentences or paragraphs.
Single lineA single line of code.
Multi-lineMultiple lines of code with the ability to show more or less strings.

When to use

  • Use a code snippet to help the user copy strings of text easily, or if you want to call out key words for the user.
  • Code snippets are typically used in code documentation to help the user get started quickly.

When not to use

  • Do not use a code snippet if you want the user to change the input value. Our code snippets are read only.

Live demo

<CodeSnippet type="single">node -v</CodeS