Component libraryCode block
Components/Essentials

Code block

Pro

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

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

Installation

Pro source is gated. Configure the @tidal-pro registry using the agent guide. Create an access key from your account after purchasing.

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

Import components/ui/tidal.css, components/ui/code-block.css, then add the component inside a tidal-scope wrapper. Its scoped design tokens keep it independent of your existing CSS.

Usage

Complete example source · Dependency and asset manifest

Loading the complete example…

API & behavior

Required code is rendered as plain text and never evaluated. Optional filename, language, caption, codeLabel, actions, wrap, lineNumbers (default true), maxHeight (default 400px, finite and at least 80px), native figure attributes/ref/className/style. The native focusable code region supports horizontal/vertical keyboard scrolling. Direction is LTR for source text even in an RTL page. Number gutter is decorative, excluded from selection and hidden when wrapping to avoid misleading line numbers. Use the actions slot for a separate TidalCopyButton; clipboard behavior remains the action's responsibility. Empty strings, tabs, Unicode and trailing newlines are preserved. No syntax parser, code execution, network or storage is introduced.

Style with the --t-* CSS variables. Set data-theme="dark" on your tidal-scope wrapper for a dark surface. Motion respects the system’s reduced-motion preference.

Building with an agent?Give it the installation guide and component catalog.