2.14.0
Code Snippet Component in Bolt
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.
npm install @bolt/components-code-snippet
{% include "@bolt-components-code-snippet/code-snippet.twig" with {
display: "block",
lang: "html",
content: "Some code snippet"
} only %}
Note: when assigning component props as HTML attributes on a web component, make sure to use kebab-case
.
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
|
Defines if the code text is inline or block. |
string
|
block
|
|
|
Language of the code text. |
string
|
html
|
|
|
Toggle between a light and dark syntax highlighting, or turn it off. Separate from Bolt theming. |
string
|
light
|
|
Code snippet can be a block of code, and
display
block
display: block;
margin: 0 0 1.65rem 0;
Well, code snippet can also be inline like this
display:inline;
display
inline
<header>
<h1>Headline</h1>
</header>
<header><h1>Headline</h1></header>
.my-css {
display: block;
}
.my-scss {
@include my-mixin;
}
<header>
<h1>Headline</h1>
</header>
import { polyfillLoader } from '@bolt/core-v3.x/polyfills';
{% include "@bolt-components-code-snippet/code-snippet.twig" with {
display: "block",
lang: "html",
content: "Some code snippet"
} only %}
<header>
<h1>Headline</h1>
</header>
<header>
<h1>Headline</h1>
</header>
<header>
<h1>Headline</h1>
</header>