Code block

Shows a real record, command or code excerpt exactly as it is, so the reader sees what Loom writes into a repository.

Atom · stable · v1.0.0 · owner: Site system lead · contract 19 of 20 points (open: figma)

Do and don't

Do: A real command

Rendered by code-block.ts

Open example: Code block · Do: A real command Use the full-page example to follow page links.

The reader can run it.

Do: A real record

Rendered by code-block.ts

Open example: Code block · Do: A real record Use the full-page example to follow page links.

It is what Loom writes.

Don't: Pseudo-code presented as real

Rendered by code-block.ts

Open example: Code block · Don't: Pseudo-code presented as real Use the full-page example to follow page links.

Invented code breaks the truthfulness rule.

Don't: Prose in a code block

Rendered by code-block.ts

Open example: Code block · Don't: Prose in a code block Use the full-page example to follow page links.

Monospace makes prose hard to read.

Rules

RuleWhyCheck
Code on the site is real output, or its caption says it is sample.The site's credibility rests on showing real artefacts.Review: Owner review of each new code block
A block that scrolls is focusable.Keyboard users cannot scroll what they cannot reach.Automated: axe scrollable-region-focusable (tests/site/pages.spec.ts)

API

PropTypeRequiredDefaultWhat it does
codestringYesThe exact code.
langstringNoyaml, json, ts or text, for the class name.

Contract details

The full contract: identity, anatomy, variants, states, tokens, layout, motion, accessibility, content, tests

Identity

AspectValue
Idcode-block
LayerAtoms
Categorytypography
OwnerSite system lead
Statusstable
Version1.0.0
Sourceapps/showcase/site/system/atoms/code-block.ts (private repository; the contract and the render function are this one module)
VersionDateChange
1.0.02026-10-26Real records and commands in Martian Mono on the terminal ground.

Use when

  • A command the reader can run, or a record from loom/. Why: Real artefacts prove the product better than descriptions.
  • A before-and-after code change. Why: The change is visible line by line.

Do not use when

  • For prose or emphasis. Why: Monospace slows reading.
  • For made-up code presented as real. Why: Code on the site is real output or is captioned as sample.

Anatomy

PartWhat it is
rootpre with a code child, language class language-<lang>.

Made of: tokens:type, tokens:colour.

Used in: finding, academy-lesson, agent-check, before-after, design-md-excerpt, replay, score-us, token-chain.

Variants

VariantWhenWhy
terminalCommands and records.The dark terminal ground marks machine text.

States

StateRendered or not applicable
defaultdefault
hoverNot applicable: A code block is not interactive, so it has no hover state.
focus-visibleScrollable blocks are focusable (tabindex=0) so keyboard users can scroll them.
activeNot applicable: A code block cannot be pressed.
disabledNot applicable: A code block has nothing to disable.
loadingNot applicable: A code block is rendered at build time and is complete when the page loads.
emptyNot applicable: A code block is not rendered without content; the builder skips it.
errorNot applicable: A code block shows no data that can fail.
currentNot applicable: A code block has no current item.
visitedNot applicable: A code block is not a link.
expandedNot applicable: A code block does not open or close.

Tokens

PartToken
root.background--term-bg
root.color--term-fg
root.font--font-mono, --fs-small, line height 1.6
root.padding--space-7
root.radius--radius

Layout

AspectValue
breakpointsRequired review at 390, 768, 1024 and 1440 px; execution is not implied by this declaration; wraps under 900 px, scrolls sideways above.
wrappingpre-wrap with anywhere breaks on phones; pre on wide screens.
textExpansionCode is not translated; Japanese pages caption it.

Spacing and rhythm

AspectValue
internal--space-7.
external--space-6 above and below in prose.
rhythmInside prose or a panel.

Motion

AspectValue
NoneStatic.

Runtime and reuse

  1. Render-only element; mount any registered child enhancements separately. Preserve required Site CSS, fonts, responsive and locale rules from nativeElement.

Accessibility passport

AspectValue
rolecode (pre)
nameLabelled by its caption when in a figure
keyboardFocusable when it scrolls.
focusIn reading order.
screenReaderRead as text.
contrast--term-fg on --term-bg 13.2:1.
targetNot a target.

Content

SlotLengthVoice
code30 linesExact, unedited output

Good: “npm run audit -- --project harbor”

Bad: “// pseudo-code that looks real”

Japanese: Code stays in English; Japanese pages say 「チェック結果は英語で表示されます」 nearby.

Icons and illustrations

None: this element uses no icon or illustration of its own.

Decisions and exceptions

Usage

16 uses across the built pages (measured by npm run site:system).

Shared styles

Base styles the code font; the .prose context supplies the pre surface, padding, wrapping and focusable scroll region.

Style owners: base, text

  • apps/showcase/site/system/styles/core/base.css
  • apps/showcase/site/system/styles/site/text.css

Remaining review: Twelve existing positive specimens pass light/dark 320/390/1440 surface, focusability and overflow checks; keyboard scrolling and manual AT review remain open.

Tests

AspectValue
unittests/unit/site-system.test.ts: renders every do and don't example through the registry and checks the classes it owns
visualNot yet: there are no screenshot baselines; the Library page is checked for sideways scroll at 1440 px by tests/site/system.spec.ts
a11ytests/site/system.spec.ts: axe (0 serious or critical) on the element's Library page in light and dark
parityscripts/site/system/check.ts: Library examples are rendered by the same render function the site imports

Figma

not-yet: The Loom Site Figma library is the last stage of the plan; this element is not mapped yet.

Open in Storybook

Start with a conversation about your system.

We read your system, show you what we found, and agree with your team what to fix first.