- Docs
- Components
- Data display
Code block
Code to read and copy: a command, a snippet, a JSON event or XML metadata, coloured, with one Copy button.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.6
- Renders
<pre>Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Playground
Every prop, live, and the code it takes.
JSON
{ "type": "user.signed_in", "tenant": "acme", "user": { "id": "usr_0001", "email": "priya@acme.in" }, "method": "passkey", "at": "2026-10-29T03:58:00Z"}Language
import { CodeBlock } from "@qeetrix/react/experimental";
<CodeBlock language="json" code={code} />02
A command
One line: the code and its Copy button, no header.
bun add @qeetrix/react @qeetrix/tokens<CodeBlock language="shell" code="bun add @qeetrix/react @qeetrix/tokens" />03
A snippet
More than one line: a header with the language and Copy, and line numbers that copying never picks up.
TSX
import { PlusIcon } from "@qeetrix/icons";import { Button } from "@qeetrix/react";export function InviteButton({ onInvite }: { onInvite: () => void }) { return <Button icon={PlusIcon} onClick={onInvite}>Invite users</Button>;}<CodeBlock language="tsx" code={snippet} />04
A title
title: the header's label in place of the language, such as the file's name.
user.signed_in
{ "type": "user.signed_in", "tenant": "acme", "user": { "id": "usr_0001", "email": "priya@acme.in" }, "method": "passkey", "at": "2026-10-29T03:58:00Z"}<CodeBlock language="json" title="user.signed_in" code={event} />05
Long lines
They scroll sideways in a named region that takes focus, so the keyboard can scroll it.
SAML metadata
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" entityID="https://id.qeet.in/saml/acme"> <IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"> <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://id.qeet.in/saml/acme/sso"/> </IDPSSODescriptor></EntityDescriptor><CodeBlock language="xml" title="SAML metadata" code={metadata} />06
Wrapped
wrap: long lines wrap under their own start, the indent kept.
SAML metadata
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" entityID="https://id.qeet.in/saml/acme"> <IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"> <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://id.qeet.in/saml/acme/sso"/> </IDPSSODescriptor></EntityDescriptor><CodeBlock language="xml" title="SAML metadata" code={metadata} wrap />