# CodeBlock · semantische Komponentenreferenz

Present selectable plain code and an independently operable copy-to-clipboard action.

Status der neuen Domänenmigration: **complete** im begrenzten Referenzumfang. Stabile Teile, tatsächlich passende Source-Selektoren, semantische Tokenwerte und nutzbare Zustands-Fixtures wurden mit dem normalen Komponentenprüfpfad und der echten React-Verwendung geprüft. [Browsernachweis](../../validation/semantic-feedback-browser-run.json); keine allgemeine Anwendungsfreigabe.

The actual source pre/code/line hierarchy and public wrap/lineNumbers/startLine semantics lead the recipe. Native 18px surface corners,16px section/content insets and 8px header gap remain semantic metrics; source 448px example widths are never fixed. Actual native text runs and line-number text specify Geist Mono Medium 14/20, despite a22.75px artwork row frame; the pinned supplied font follows those text values. Compact 12/16 and 28rem maximum scroll height are explicit reference decisions. Native unbound highlighted zinc at50% is retained for light mode, with an explicit 10% light foreground tint in dark mode for readable text; added-line colors and destructive inset stroke are explicit visual decisions because pinned wrapper classes define the variants without these scalar values. The visible +/− text and legend carry diff meaning independently of color. Code content remains LTR inside RTL hosts. Counter-only line numbers have empty speech alternative where supported, and Copy always uses the caller value rather than rendered numbers or diff DOM. Headerless actions reveal on hover, focus-within and coarse pointers; the real native Button remains independently reachable. Copy success,2000ms reset and swallowed rejection remain actual source behavior; persistent selection instructions provide the concrete fallback. Root never executes code or adds a syntax highlighter.

[Stabile Anatomie und tatsächliche Source-/Caller-Bindungen](component.json), [CEM](interface.json), [semantische Zustands-/Variantenregeln](layout.css), [brauchbare Fixtures](stories.json). Native Muster, Hashes und Messwerte bleiben vollständig separat in [Quellmustern](figma/source-specimens.json) und [Traceability](figma/traceability.json).

Die veröffentlichten Props/Callbacks und der [führende SCXML-Aktor](behavior.scxml) bleiben die Quelle des tatsächlichen Verhaltens. [HTML/ARIA](accessibility.html) und [Projektionsregeln](accessibility.rules.json) benennen die konkrete Verwendung, einschließlich notwendiger Caller-Beschriftung. Selectorbindungen sind ein expliziter React-/DOM-Adaptervertrag, keine erfundenen automatischen Shadow-DOM-Exports.

Root variant=default|destructive and size=default|sm only style div content. Content is native pre with nested code, dir=ltr and tabIndex0; wrap defaultsfalse, lineNumbersfalse, startLine1 controls the CSS line counter. With string children and numbering, one trailing newline is removed before splitting; empty CodeBlockLine deliberately emits a newline. No syntax highlighter or executable code engine is built in. CopyButton requires value:string, defaults ghost/icon-xs, calls caller onClick before navigator.clipboard.writeText(value), and does not inspect defaultPrevented. Successful promise sets copied=true, aria-label=Copied and a polite live text; first copied=true schedules reset after2000ms. Repeated success while already copied does not restart that effect timer. Rejected promises are swallowed, preserving the previous copied state; no onCopied/onCopyError event exists. Missing navigator.clipboard can throw synchronously before the promise catch. This reference requires a supported secure clipboard context for Copy and provides persistent native text-selection instructions as the fallback. The copy value is exact caller text, not inferred from formatted/numbered DOM.

Native Copy Button supports Enter/Space; disabled suppresses its click. The focusable pre supports native selection/scrolling and Tab leaves it. Escape does not revert code or cancel a clipboard write already requested. Copy does not move focus. A descriptive code heading/instructions are caller supplied, not automatic CodeBlockTitle semantics.

[Originale React-Quellen und Versionen](../../sources/manifest.json), [nativer FIG-/PNG-Beleg](figma/figma-observations.json) und [tatsächliches Source-Prüfziel](provenance://source/apps%2Fshadcn-reference-lab%2FREADME.md). `release:false`; kein allgemeines Pixel-/Framework-/AT-Zertifikat.
