v0.3.1 StableFoundation ComponentReact 18 & 19Zero Runtime CSS

CodeBlock

Plain, selectable code with an optional copy action.

Interactive preview

Theme customization · css
:root {
  --dvy-brand: #282724;
  --dvy-radius-md: 0.5rem;
}

Usage

import { CodeBlock } from "@devvy-ui/react";

<CodeBlock label="Theme token" language="css" code="--dvy-brand: #282724;" />

API reference

Native HTML attributes, className, style and a forwarded ref are supported. Component-specific props:

PropTypeDefaultDescription
codestringrequiredLiteral code text.
label / languagestringCode example / textFigure and code description.
copyablebooleantrueCopy action.
lineNumbersbooleanfalseDecorative line markers excluded from copying.

Accessibility & behavior

Platform Behavior & Guidelines

Code renders as escaped text, never HTML. Native horizontal scrolling preserves formatting. Copy uses the existing clipboard/manual fallback; no syntax-highlighting dependency.

Source ownership

Run npx @devvy-ui/cli init once in your React project, then add the source:

npx @devvy-ui/cli add code-block

Make the source yours.

Start from the canonical implementation used by the package and registry. Change the code, keep the MIT notice, and build the behavior your project needs.

CodeBlock.tsxREACT / TSX

Edit your own copy. Downloaded source uses your changes; the component preview above uses the shipped version. Run the source installer first to include shared helpers.