Skip to content
Design System
GitHub

Code block

v0.19.0Beta

Code or a command with a copy button: wraps a command between words, scrolls source sideways, hides a one-time secret until shown. Takes a highlighter's output as children.

Terminal
dvc import https://git.syncrobotic.me/datacore/warehouse-scans data/pallets/2026-11 --rev v3.2.0

Code block command

Install
npx shadcn add @syncrobotic/code-block

Also installs: lucide-react, @syncrobotic/cn, @syncrobotic/button, @syncrobotic/copy-button, @syncrobotic/table

Overview

Code or a command to read and copy, in a frame with its title and a copy button.

When to use

  • Install and import commands (dvc import, npx shadcn add) and curl examples.
  • A one-time API key or webhook secret, hidden until shown.
  • Source and API responses in docs and settings pages.

Use something else

More examples

States and real uses. Each example is also a Storybook story and a visual regression test.

json
{
  "id": "dev_7Q2M9KX4",
  "name": "Taipei warehouse — line 2",
  "status": "online",
  "lastHeartbeatAt": "2026-11-19T08:42:17.000Z",
  "hardware": { "gpus": [{ "name": "NVIDIA RTX 6000 Ada Generation", "memoryTotalMiB": 49140 }] }
}

Code block scrolls

list-devices.ts
import { createClient } from "@localmind/portal"

const portal = createClient({ apiKey: process.env.LOCALMIND_API_KEY! })
const devices = await portal.projects.devices.list("prj_warehouse_north", { status: "online", limit: 20 })
console.log(devices.items.map((d) => d.name))

Code block with title

API key
Hidden

Copy it now: it is shown once and cannot be retrieved later.

Code block secret

Terminal
curl https://portal.syncrobotic.me/api/v1/projects/prj_warehouse_north/devices \
  -H "Authorization: Bearer $LOCALMIND_API_KEY"

Code block curl

Usage rules

  • Copy copies code exactly, whatever the block shows: highlighted children, wrapped lines or a hidden secret.
  • wrap="words" for shell commands, so a phone never cuts a package name in two; wrap="none" for source, which scrolls sideways with a fade on the side that hides text.
  • A one-time secret (an API key) is secret: dots until Show is pressed. Never put the value in the title or a label; say beside it that it is shown once.
  • No highlighter inside: pass shiki's output (or any <pre>) as children. Line numbers only for source people discuss by line.

Changelog

  • 0.19.02026-11-20labels.copy(title) names the copy button, so it can be translated; copyLabel still sets it as is.
  • 0.18.02026-11-19First release: a framed block with a title and CopyButton; wrap="words" for shell commands, wrap="none" scrolls with the table's fade and takes focus; secret hides a one-time value behind Show; optional line numbers; a highlighter's output (shiki) as children.

How to upgrade