Code Snippet

Monospace Font Styles for Code Text

Code snippet shows text in a style that is best fit for a monospace font. Part of the Bolt “Components” CSS framework that powers the Bolt Design System.

Install via NPM
npm install @bolt/components-code-snippet
  {% include "@bolt-components-code-snippet/code-snippet.twig" with {
  display: "block",
  lang: "html",
  content: "Some code snippet"
} only %}

Monospace Font Styles for Code Text

Name Type Value(s) Description Default
display string
  • block OR inline

Display

Defines if the code text is inline or block.

block
lang string
  • css, html, js, scss, twig

Language

Language of the code text.

html
syntax string
  • light, dark, none

Syntax Highlighting

Toggle between a light and dark syntax highlighting, or turn it off. Separate from Bolt theming.

light

Code snippet can be a block of code, and display is set to block by default.

  display: block;
margin: 0 0 1.65rem 0;

Well, code snippet can also be inline like this display:inline; when you set display to be inline instead.

block:

  

Headline

inline:

Headline

css:

  .my-css {
  display: block;
}

scss:

  .my-scss {
  @include my-mixin;
}

html:

  

Headline

javascript:

  import { polyfillLoader } from '@bolt/core';

twig:

  {% include "@bolt-components-code-snippet/code-snippet.twig" with {
  "display": "block",
  "lang": "html",
  "content": "Some code snippet"
} only %}

light:

  

Headline

dark:

  

Headline

none:

  

Headline