Code snippet
Color
Single line
Element | Property | Color token |
---|---|---|
Container | background | $layer * |
Code | text color | $text-primary |
Copy button | See ghost button - icon only | |
Container:focus | border | $focus |
* Denotes a contextual color token that will change values based on the layer it is placed on.
![States of a single line codesnippet States of a single line codesnippet](/static/243fa7e2f769b46e207007061dd2a0c7/3cbba/code-snippet-style-color-1.png)
Enabled, focus, hover, and active states
Multi-line
Element | Property | Color token |
---|---|---|
Container | background | $layer * |
Code | text color | $text-primary |
Icon | svg | $icon-primary |
Copy button Snippet button | See ghost button - icon only | |
Container:focus | border | $focus |
* Denotes a contextual color token that will change values based on the layer it is placed on.
![States of a multi-line codesnippet States of a multi-line codesnippet](/static/2109953267eb5fb4df878e06e265bfc7/3cbba/code-snippet-style-color-2.png)
States for copy button: active, enabled, hover, focus, disabled
![States of a multi-line codesnippet States of a multi-line codesnippet](/static/343b2171a2f2ef3e0c847bf82673d847/3cbba/code-snippet-style-color-3.png)
States for show toggle: enabled, hover, focus
Inline snippet
Element | Property | Color token |
---|---|---|
Container | background-color | $layer * |
Code | text color | $text-primary |
Container:hover | background-color | $layer-hover * |
Container:focus | focus | $focus |
Container:active | background-color | $layer-active * |
* Denotes a contextual color token that will change values based on the layer it is placed on.
![States of an inline codesnippet States of an inline codesnippet](/static/44b55da986ef61294b876c81ba588be1/3cbba/code-snippet-style-color-4.png)
States for inline codesnippet: enabled, hover, active, focus
Syntax colors
Carbon has defined a set of accessible syntax colors. View an incontext example on CodePen.
Typography
Element | Font-size (px/rem) | Font-weight | Type token |
---|---|---|---|
Code text | 12 / 0.75 | Regular / 400 | $code-01 |
Structure
Single line
Element | Property | px / rem | Spacing token |
---|---|---|---|
Container | height | 40 / 3 | – |
max-width | 768 / 48 | – | |
padding-right | 48 / 3 | $spacing-09 | |
padding-left | 16 / 1 | $spacing-05 |
![code snippet style 1 code snippet style 1](/static/6dfcc8cea79f3d7c61b07c88b9acd73a/3cbba/code-snippet-style-1.png)
Structure and spacing measurements for code snippet | px / rem
Multi-line code snippet
Element | Property | px / rem | Spacing token |
---|---|---|---|
Container | min-height | 288 / 18 | – |
max-height | Varies based on content | – | |
max-width | 768 / 48 | – | |
padding | 16 / 1 | $spacing-05 | |
padding-right | 40 / 2.5 | $spacing-08 | |
Icon | height, width | 16px | – |
Snippet button | height, width | 40 / 2.5 | – |
Copy button | height, width | 32 / 2 | – |
![Structure and spacing measurements for multi-line snippet Structure and spacing measurements for multi-line snippet](/static/e4a79b5a36cf6b86b6bab467c0bb8876/3cbba/code-snippet-style-2.png)
Structure and spacing measurements for multi-line snippet | px / rem
Inline code snippet
Element | Property | px / rem | Spacing token |
---|---|---|---|
Container | height | 16 / 1 | – |
width | Varies based on content | – | |
border-radius | 2 | - | |
Code | padding-right, padding-left | 8 / 0.5 | $spacing-03 |
![Structure and spacing measurements for inline snippet Structure and spacing measurements for inline snippet](/static/8908efff6ee4b995aca64ef1cc3a906f/3cbba/code-snippet-style-3.png)
Structure and spacing measurements for inline code snippet | px / rem