VAULT // NEXTUI

CodeBlock

Syntax-highlighted code block with a header showing the language or file title and a one-click copy button. Client component with clipboard feedback.

$npx @voltenworks/shipui add codeblock --theme vault
Or install the base component for free:
Live Preview
Open full demo
voltenworks.com/shipui/vault/demo/components
Usage
TSX
<CodeBlock lang="bash">npm install @scope/package</CodeBlock>
Variants
<CodeBlock lang="bash">npm install @scope/package</CodeBlock>
<CodeBlock lang="ts" title="lib/client.ts">export const client = createClient()</CodeBlock>
Source
TSX
'use client'

import { useState } from 'react'
import type * as React from 'react'

interface CodeBlockProps {
  lang:       string
  title?:     string
  children:   string
}

export function CodeBlock({ lang, title, children }: CodeBlockProps): React.JSX.Element {
  const [copied, setCopied] = useState(false)

  function handleCopy(): void {
    void navigator.clipboard.writeText(children).then(() => {
      setCopied(true)
      setTimeout(() => setCopied(false), 2000)
    }).catch(() => { /* copy failed silently */ })
  }

  return (
    <div className="vault-code-block">
      <div className="vault-code-block-header">
        {title ? (
          <span className="vault-code-block-title">{title}</span>
        ) : (
          <span className="vault-code-block-lang">{lang}</span>
        )}
        <button type="button" className="vault-copy-btn" onClick={handleCopy}>
          {copied ? (
            <>
              <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                <polyline points="20 6 9 17 4 12" />
              </svg>
              Copied
            </>
          ) : (
            <>
              <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                <rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
                <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
              </svg>
              Copy
            </>
          )}
        </button>
      </div>
      <div className="vault-code-block-body">
        <pre>{children}</pre>
      </div>
    </div>
  )
}
Preview in theme demoGet full theme, $29
Works withNext.js 15React 19Tailwind v4TypeScript 5
More from VAULT // NEXT
VAULT // NEXTUI

Button

Dark docs-style button with primary, secondary, and ghost variants in three sizes. Renders as a Next.js Link for internal hrefs and a plain anchor for external links.

VAULT // NEXTUI

Badge

Semantic status badge with six color variants: green, blue, yellow, red, purple, and muted. Suited for version tags, API status labels, and changelog markers.

VAULT // NEXTUI

Callout

Inline callout block with four semantic variants: info, warn, tip, and danger. Each renders a matching icon and left-accent color for inline documentation alerts.

VAULT // NEXTUI

Card

Feature card with icon, title, optional badge, and description. Accepts an accent prop for a highlighted border variant. Icon set: book, code, key, zap, layers, terminal, shield, cpu.