Code block preview
Readable source code with a filename, optional line numbers, wrapping and a scrollable viewport.
pro · Essentials · composite
When to use
- Use it when a page needs readable source code with a filename, optional line numbers, wrapping and a scrollable viewport.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.
Alternatives
- Choose tidal-button instead when press, loading, success and disabled states is the actual interface need, rather than code block.
Configure components.json and the @tidal-pro namespace before installing Pro components.
Installation
npx shadcn@latest add @tidal-pro/code-blockImport components/ui/tidal.css, components/ui/code-block.css. Wrap installed components in tidal-scope.
Preview

Minimal example
import"./components/ui/tidal.css";
import"./components/ui/code-block.css";
import{TidalCodeBlock}from"./components/ui/code-block";
export default()=><div className="tidal-scope"><TidalCodeBlock code={"value"}/></div>;API and props
TidalCodeBlock.code (required)stringSource text is rendered as text, never evaluated or interpreted as HTML.
TidalCodeBlock.actionsReactNodeSupply a TidalCopyButton or any other native action.
TidalCodeBlock.captionReactNodeOptional caption value accepted by this exported component.
TidalCodeBlock.codeLabelstring | undefinedOptional code label value accepted by this exported component.
TidalCodeBlock.filenamestring | undefinedOptional filename value accepted by this exported component.
TidalCodeBlock.languagestring | undefinedOptional language value accepted by this exported component.
TidalCodeBlock.lineNumbersboolean | undefinedThe number gutter is omitted while wrapping so it cannot mislabel visual lines.
TidalCodeBlock.maxHeightnumber | undefinedMaximum scrolling body height in pixels. Omit for the 400px default.
TidalCodeBlock.wrapboolean | undefinedOptional wrap value accepted by this exported component.
Complete usage
Full example, stylesheet imports, API and accessibility documentation
Gotchas
- Install the declared registry dependencies and render inside a tidal-scope with the foundation stylesheet loaded.