Übersicht FarbenTypografieAbstände & RasterIcons ButtonButton GroupIcon ButtonLink CheckboxCheckbox GroupChipChip GroupComboboxDate PickerFieldField LabelFieldsFile UploadFormForm SectionInputInput GroupOTP InputPasswordRadioRadio GroupRange SliderReset ButtonSave ButtonSearchSegmented ControlSelectSliderSwitchTextareaTime Picker AvatarAvatar GroupBadgeChartCode BlockCopy ValueData TableInline StatKey ValueList GroupList RowsMeta ItemQR CodeStatStat StripTableTag AlertEmpty StateGuideLive StatusMessagesProgressSkeletonToast DialogDrawerDropdownMenuMenu ItemPopoverTooltip BreadcrumbContent NavigationDate NavigationPaginationSidebarStepperTabsTheme SwitchTopbar AccordionAccordion ItemApp ShellCardDividerFooterPage HeaderSection HeaderSplit Panel DashboardListeFormularDetailansichtEinstellungenMehrschritt-AssistentLeerer StartLoginFehlerseite IconsMusterAdmin

Code Block

Konfiguration

Datei mit Kopf, Kopieren und Herunterladen

[Interface] PrivateKey = <wird nur einmal angezeigt> Address = 10.0.4.17/32 DNS = 10.0.0.53 [Peer] PublicKey = AbCdEfGhIjKlMnOpQrStUv0= Endpoint = vpn.example.com:51820 AllowedIPs = 10.0.0.0/16
Code<div style="max-width: 560px"> {% tc_code_block filename="wg-notebook-beispiel.conf" download %}[Interface] PrivateKey = &lt;wird nur einmal angezeigt&gt; Address = 10.0.4.17/32 DNS = 10.0.0.53 [Peer] PublicKey = AbCdEfGhIjKlMnOpQrStUv0= Endpoint = vpn.example.com:51820 AllowedIPs = 10.0.0.0/16{% endtc_code_block %} </div>

Kommentare und Einzeiler

Kommentarzeilen sind gedämpft, kurze Befehle ohne Kopf

# Zertifikat erneuern curl -X POST https://api.example.com/v1/certificates/42/renew \ -H 'Authorization: Bearer <token>' GET /v1/zones/example.com/records?type=CNAME 2026-11-12 14:59:43 INFO Verbindung zu 10.0.4.17 hergestellt
Code<div style="max-width: 560px" class="tc-stack"> {% tc_code_block language="Shell" %}# Zertifikat erneuern curl -X POST https://api.example.com/v1/certificates/42/renew \ -H 'Authorization: Bearer &lt;token&gt;'{% endtc_code_block %} {% tc_code_block# code="GET /v1/zones/example.com/records?type=CNAME" %} {% tc_code_block# code="2026-11-12 14:59:43 INFO Verbindung zu 10.0.4.17 hergestellt" copy=False wrap %} </div>

HTML und JS-API

<tc-code-block> direkt im Markup; copy() und die Events tc-copy / tc-error.

10.0.4.17 notebook.example.com 10.0.4.18 tablet.example.com
copy()
Code<div class="tc-stack" style="--tc-gap: 12px; max-width: 560px"> <tc-code-block id="raw-code" filename="hosts.txt" download>10.0.4.17 notebook.example.com 10.0.4.18 tablet.example.com</tc-code-block> <div class="tc-cluster"> <tc-button id="raw-code-copy" variant="outlined" size="sm" icon="copy">copy()</tc-button> <span id="raw-code-log" class="tc-text-body-sm tc-text-secondary" aria-live="polite"></span> </div> </div> <script> (function () { var block = document.getElementById('raw-code'); var log = document.getElementById('raw-code-log'); document.getElementById('raw-code-copy').addEventListener('click', function () { block.copy(); }); block.addEventListener('tc-copy', function () { log.textContent = 'tc-copy'; }); block.addEventListener('tc-error', function () { log.textContent = 'tc-error (keine Berechtigung)'; }); })(); </script>

API

OptionStandardWerteBeschreibung
code''–Code text (escaped).
filename''–Header title and download file name, e.g. "wg-notebook.conf".
language''–Language hint, shown when no file name is set.
copyTrue–Show the copy button.
downloadFalse–Show a download button that saves the text as filename.
download_url''–Download from this URL instead of the shown text.
wrapFalse–Wrap long lines instead of scrolling horizontally.
max_height''–CSS max height of the body, e.g. "320px" (scrolls).

Verwendung

{% load components tomcom_theme %} {% tc_code_block code="…" filename="…" %}…{% endtc_code_block %} {% tc_code_block# %} {# inline form without content #}

Zusätzliche Attribute (z. B. class, aria-*, data-*) und HTMX-Kurzformen (get, post, get_url, post_url, target, swap, trigger, confirm) werden an das Element „root“ durchgereicht.