TidalUI

Code block preview

Readable source code with a filename, optional line numbers, wrapping and a scrollable viewport.

pro · Essentials · composite

When to use

Alternatives

Configure components.json and the @tidal-pro namespace before installing Pro components.

Installation

npx shadcn@latest add @tidal-pro/code-block

Import components/ui/tidal.css, components/ui/code-block.css. Wrap installed components in tidal-scope.

Preview

Code block component preview

Open interactive 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)
string

Source text is rendered as text, never evaluated or interpreted as HTML.

TidalCodeBlock.actions
ReactNode

Supply a TidalCopyButton or any other native action.

TidalCodeBlock.caption
ReactNode

Optional caption value accepted by this exported component.

TidalCodeBlock.codeLabel
string | undefined

Optional code label value accepted by this exported component.

TidalCodeBlock.filename
string | undefined

Optional filename value accepted by this exported component.

TidalCodeBlock.language
string | undefined

Optional language value accepted by this exported component.

TidalCodeBlock.lineNumbers
boolean | undefined

The number gutter is omitted while wrapping so it cannot mislabel visual lines.

TidalCodeBlock.maxHeight
number | undefined

Maximum scrolling body height in pixels. Omit for the 400px default.

TidalCodeBlock.wrap
boolean | undefined

Optional wrap value accepted by this exported component.

Complete usage

Full example, stylesheet imports, API and accessibility documentation

Gotchas