Typography · CodeBlock

CodeBlock

Multi-line code block primitive. Renders a {`

`} shell wrapping a {`
`}
			body, with an optional header strip carrying title, language badge, and copy-to-clipboard
			button. The copy button is a leaf utility — it does not emit Sema events. Single morfo
			part. Eidos-native: no soma backing, no semantic events.
		

parts{compiled.parts.order.length} events0 variants3 copyopt-in scopeeidos
{content}
trace {trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`} · variant {variant} language {language || 'none'} · copy {showCopy ? 'on' : 'off'}
{#if tab === 'live'}

Controls

CodeBlock is eidos-native — no soma split. The variant picks chrome; the header strip auto-renders when title, language, or showCopy is present.

eidos props · block + header
soma n/a · code-block is eidos-native — equivalent markup shown svelte
{somaSnippet}
eidos visual · variant + header composition svelte
{eidosSnippet}
{/if} {#if tab === 'api'}

API reference

CodeBlock ships a structural shell with an optional header (title + language badge + copy button) and a {`

`} body. Composition over visibility: omit
				title + language + set showCopy=false to drop the
				header entirely.
			

Props
PropTypeDefaultNotes
titlestring—Filename / label. Appears in the header.
languagestring—Language badge. Stamped as data-language on inner {``}.
showCopybooleantrueRender the copy-to-clipboard button.
variant'surface' | 'outline' | 'ghost''surface'Visual chrome.
size'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'inheritCode font size override.
tagStylestring—Extra inline CSS.
Reference comparison
LibraryClosest equivalentDifference
radix-themes<Code> + customRadix has no dedicated multi-line surface — UIX ships the header + copy as built-in.
chakra-uicomposedChakra composes Code + Box + IconButton; UIX bundles them.
mantine<CodeHighlight>Mantine ships Shiki integration; UIX reserves data-language for a separate action.
shadcn/uirecipe-onlyshadcn provides Tailwind classes; UIX ships a proper component.
{/if} {#if tab === 'morfo'}

Morfo contract

FieldValue
name{codeBlockMorfo.name}
kebab{codeBlockMorfo.kebab}
scope{codeBlockMorfo.scope.join(', ')}
parts{partsList.length}
events0
Parts
{#each partsList as part} {/each}
kebabmarkerelementarchetypeoptional
{part.kebab} [{part.marker}] <{part.defaultElement}> {part.archetype} {part.optional ? 'yes' : 'no'}

The Provider stamps data-code-block + data-variant. Internal header / copy / pre / code leaves are eidos-only attrs (data-code-block-header, data-code-block-title, etc.) — the morfo declares only the Provider because the inner parts are consumed exclusively by the recipe.

{/if} {#if tab === 'sema'}

sema · events

CodeBlock declares no semantic events. The copy button is a utility leaf — clipboard write, no semantic transition. By the 2-of-3 rule, a commit-copy event would only be consumed by eidos (visual flip) — not enough to justify a morfo extension. If a consumer needs sema on copy (e.g. fulfilment of a tutorial step), they compose CodeBlock inside a Stepper or Form that owns the verb.

{/if} {#if tab === 'recipe'}

Eidos recipe

Recipe lives in src/uix/eidos/components/code-block/code-block.css. The outer shell selector is [data-code-block]; the header / pre / code leaves use eidos-only attrs.

SelectorOwnerPurpose
[data-code-block]morfoProvider marker.
{`[data-code-block][data-variant='surface'|'outline'|'ghost']`}eidosChrome treatment.
[data-code-block-header]eidosTitle + lang + copy strip.
[data-code-block-copy]eidosCopy button with :hover / :focus-visible / [data-copied] states.
[data-code-block-pre] / [data-code-block-code]eidosBlock body.
{/if} {#if tab === 'a11y'}

Accessibility

ConcernContract
RoleThe block is a generic {`
`} wrapping {`
`}. AT announce the code content.
Copy buttonaria-label="Copy code to clipboard" in English. Focus ring via :focus-visible.
Copied feedbackButton text flips from "Copy" to "Copied" + data-copied color shift. Re-announced by AT because the text content changes.
KeyboardCopy button reachable via Tab. Enter / Space activate. No custom keyboard contract.
{/if}