CodeBlock

v1.0.0

A tabbed code display component that toggles between a live preview and highlighted source code with copy support.

Examples

Basic usage

With icons and content

With complex children

ActiveStatus indicator

Multiple code blocks

$ npm install framer-motion class-variance-authority
import { Button } from "@/components/button";

API

All available props for the CodeBlock component.

Property
Type
Default
Description
codestringrequiredThe source code shown in the Code tab.
languagestring"tsx"Language for syntax highlighting (tsx, jsx, bash, etc.).
childrenReactNodeContent rendered in the Preview tab.
showLineNumbersbooleanfalseShows line numbers in the code view.
fileNamestringFile name shown in the code header.
variant"modern" | "minimal""modern"Visual style variant.
tab"preview" | "code"Controlled active tab.
onTabChange(tab) => voidCallback when the active tab changes.
© 2026 Venti UI Labs.