Skip to content
MIZU.

CodeBlock

Selectable source with a real copy action and room for long lines.

View .md

Live — this one is real

app.tsx
import { Button } from "mizu-ui";

<Button>Make something</Button>

Usage

tsx
import { CodeBlock } from "mizu-ui";

export function Example() {
  return (
    <CodeBlock
      filename="app.tsx"
      language="tsx"
      code={
        'import { Button } from "mizu-ui";\n\n<Button>Make something</Button>'
      }
    />
  );
}

Source & setup

Add this component to your project with the shadcn CLI. The command copies its source into your configured UI directory, with base.css, Mizu’s tokens, and the stylesheets that hold its rules. Each rule lives in one stylesheet, so components you add together never repeat CSS. In a project without a components.json, run npx shadcn@latest init 0xuser64bit/mizu/preset first: plain init installs shadcn’s theme into your global CSS. Then load the fonts.

sh
npx shadcn@latest add 0xuser64bit/mizu/code-block 0xuser64bit/mizu/button

The example also uses Button, so the command adds it too.

Every component imports from its own path, its name in kebab case. Its source, content/Typography.tsx, also holds Kbd, Quote, Prose, LinkCard and FileCard. Each has its own command and path; adding one after this copies only its small entry file. To paste the example, replace its mizu-ui import with:

tsx
import { CodeBlock } from "@/components/ui/mizu/code-block";
import { Button } from "@/components/ui/mizu/button";

For npm imports, import mizu-ui/styles.css once. Fonts are optional via mizu-ui/fonts.css. Override --mizu-* tokens or use className for local styling. Uses native React and CSS; install the package peers for root imports. A Server Component: it renders on the server, with no client JavaScript of its own.

Inspect content/Typography.tsx

Source is included in the npm package under src/content/Typography.tsx.

Open full source ↗

Props

PropTypeDefaultDescription
codestring—Complete source text.
language / filenamestring—Caption metadata; no syntax parser is loaded.
labelstringfilename, or “{language} code”Names the scrollable region. Give each block on a page its own, such as “Install command”.

Accessibility

Focus the preformatted region to scroll. Each block is a named region, so give blocks on one page distinct labels. CopyButton reports clipboard failure. Content is React-escaped, never injected HTML.

Motion

Static source display.

Works alongside