Theme: ← Übersicht Tokens

Code-Block

Code-Fenster im Syntax-Stil: dunkle Flaeche in jedem Theme (color.code.*-Tokens), Traffic-Dots, Dateinamen-Tab, Kopieren-Knopf, Zeilennummern, serverseitiges Syntax-Highlighting (php/js/json/bash/html/css). 2.1.0: feste Texte mehrsprachig (invisible_i18n, texte.json). 2.2.0: Quelltext bis 200000 Zei

Components v2.3.1 Inhalt WebsiteAppDesktop component.code-block

Nutzt: ui.icon

Beispiele

PHP mit Highlighting + Zeilennummern
beispiel.phpphp
// Tür 1: Framework als Bibliothek
$rows = kunden_rest_list(['limit' => 25]);
echo invisible_render_id('component.table', [
    'columns' => $spalten,
    'rows'    => $rows,
]);
JSON
manifest.jsonjson
{
  "id": "ui.button",
  "version": "1.0.0",
  "targets": ["web.document"],
  "copyable": true,
  "order": 12
}
Ohne Sprache (nur escaped)
Foundations
└── Layouts
    └── UI Elements
Script-Injection bleibt Text
js
const evil = '<script>alert(1)</script>';

Eigenschaften

PropTypDefaultBuilder-Label
code *string—Quelltext
filenamestring""Dateiname (Kopfzeile)
languagestring""Sprache (Label)
lineNumbersbooleanfalseZeilennummern
copyablebooleantrueKopieren-Knopf
tonestring: dark | theme"dark"Farbgebung
dotsbooleantrueFenster-Punkte
paddingstring: standard | none | sm | md | lg | xl"standard"Innenabstand (standard = Baustein-Wert)
marginstring: standard | none | sm | md | lg | xl"standard"Aussenabstand
borderstring: standard | none | hairline | strong"standard"Rahmen
radiusstring: standard | none | control | surface | pill"standard"Ecken-Rundung
textColorstring""Textfarbe (Token; leer = Standard)
backgroundColorstring""Hintergrundfarbe (Token; leer = Standard)
shadowstring: standard | none | sm | md | lg"standard"Schatten
widthstring: standard | full"standard"Breite
alignSelfstring: standard | start | center | end"standard"Ausrichtung im Elternteil
anchorstring""Anker-ID (Sprungziel, z. B. fuer Nav-Links)

* Pflicht-Prop

Events & Slots

Events: ⚡ copy — im Surface per on: {<event>: {action, params}} verdrahtbar.

Stellschrauben (Komponenten-Tokens)

Ebene 3 — aus dem CSS generiert (Registry). Umverdrahtbar per Hüllen-Komposition, ohne Markup-Eingriff; künftige Regler-Quelle des Component Builders.

TokenDefault
--code-block-code-bordervar(--color-code-border)
--code-block-code-commentvar(--color-code-comment)
--code-block-code-keywordvar(--color-code-keyword)
--code-block-code-line-numbervar(--color-code-line-number)
--code-block-code-mutedvar(--color-code-muted)
--code-block-code-numbervar(--color-code-number)
--code-block-code-propertyvar(--color-code-property)
--code-block-code-stringvar(--color-code-string)
--code-block-code-surfacevar(--color-code-surface)
--code-block-code-surface-raisedvar(--color-code-surface-raised)
--code-block-code-textvar(--color-code-text)
--code-block-code-variablevar(--color-code-variable)
--code-block-elevation-overlayvar(--elevation-overlay)
--code-block-radius-fullvar(--radius-full)
--code-block-radius-smvar(--radius-sm)
--code-block-radius-surfacevar(--radius-surface)

Genutzte Design-Tokens

border.hairlinecolor.border.defaultcolor.code.bordercolor.code.commentcolor.code.keywordcolor.code.line-numbercolor.code.mutedcolor.code.numbercolor.code.propertycolor.code.stringcolor.code.surfacecolor.code.surface-raisedcolor.code.textcolor.code.variablecolor.surface.defaultcolor.surface.sunkencolor.text.accentcolor.text.defaultcolor.text.linkcolor.text.mutedduration.fasteasing.standardelevation.overlayfont.family.defaultfont.family.monoleading.baseradius.fullradius.smradius.surfacesize.1size.2size.3size.4size.8text.smtext.xs

LLM-Notizen

component.code-block

Code-Fenster im Syntax-Stil mit Traffic-Dots, Dateinamen-Tab, Kopieren-Knopf und Zeilennummern.

Wann nutzen

  • Für dargestellten Quelltext mit serverseitigem Syntax-Highlighting (php/js/json/bash/html/css).
  • Für kurzen Inline-Code eher ein Text-/Fließtext-Baustein.

Wichtige Props

  • code * = Quelltext.
  • filename = Dateiname in der Kopfzeile.
  • language = Sprach-Label (steuert das Highlighting).
  • lineNumbers = Zeilennummern anzeigen (Default false).
  • copyable = Kopieren-Knopf anzeigen (Default true).

Beispiel-Node

{ "definition": "component.code-block", "props": { "code": "echo 'hallo';", "filename": "demo.php", "language": "php", "lineNumbers": true, "copyable": true } }

Hinweise

  • Emittiert copy beim Kopieren (nur bei copyable: true).
  • Die dunkle Fläche kommt in jedem Theme aus den color.code.*-Tokens.