The design system styles three code-related elements: inline code, block-level pre, and keyboard shortcuts kbd. All use the mono font ().
Inline code
Use for the main text colour.
<p>Use <code>var(--text-primary)</code> for the main text colour.</p>
Inline code gets a subtle background, small padding, and rounded corners. It uses word-break: break-word to wrap within narrow containers.
Code blocks
.card {
background-color: var(--background-primary);
color: var(--text-primary);
border-radius: var(--radius-m);
}
<pre><code>.card {
background-color: var(--background-primary);
color: var(--text-primary);
}</code></pre>
Code blocks use pre with a nested code element. The inner code resets inline code styles (background, padding, border-radius) so they don't stack.
Keyboard shortcuts
<kbd>⌘</kbd> + <kbd>K</kbd>
The kbd element renders with a subtle 3D key appearance using border and box-shadow.
Combining kbd elements
Press Ctrl + Shift + P to open the command palette.
<p>Press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> to open the command palette.</p>
Accessibility
codeandpreelements are announced by screen readers as codekbdis announced as "keyboard input" by most screen readers- Ensure code blocks have sufficient colour contrast in both light and dark modes
Usage rules
Do:
- Use
codefor inline references to variables, functions, filenames - Use
pre > codefor multi-line code examples - Use
kbdfor keyboard shortcuts and key references
Don't:
- Don't use
codefor emphasis — usestrongoreminstead - Don't use
prewithout a nestedcodeelement
CSS reference
This section documents how the component is built. For usage, see the sections above.
Inline code
| Property | Value |
|---|---|
| Font family | |
| Font size | calc(var(--body-size) - .2em) |
| Background | color-mix(in srgb, var(--text-primary), var(--alpha-5)) |
| Padding | var(--space-2xs) var(--space-xs) |
| Border radius | |
| Color | |
| White space | nowrap |
Code blocks (pre)
| Property | Value |
|---|---|
| Background | |
| Border | var(--border-s) solid var(--border-faded) |
| Padding | |
| Overflow | overflow-x: auto |
| Font family | |
| Font size | calc(var(--body-size) - 2px) |
| Line height |
pre code resets the inline code background, padding, and border-radius to prevent stacking.
Keyboard shortcut (kbd)
| Property | Value |
|---|---|
| Display | inline-block |
| Padding | var(--space-xs) var(--space-s) |
| Font family | |
| Font size | |
| Line height | |
| Color | |
| Background | |
| Border | var(--border-s) solid var(--border-secondary) |
| Border radius | |
| Box shadow | 0 1px 0 var(--border-secondary) |
Selectors
| Selector | Purpose |
|---|---|
code |
Inline code styling |
pre |
Code block container |
pre code |
Resets inline code styles inside blocks |
kbd |
Keyboard shortcut key appearance |