CodeSnap

Code Output

Learn how to use the code output feature in your application

Code Output

Learn how to use the code output feature in your application.

Basic Usage

import { CodeOutput } from '@your-package-name'
 
function App() {
  return (
    <CodeOutput
      language="javascript"
      value={output}
      theme="vs-dark"
    />
  )
}

Features

  • Syntax highlighting
  • Line wrapping
  • Copy to clipboard
  • Error highlighting
  • Output formatting

Configuration Options

const config = {
  language: 'javascript',
  theme: 'vs-dark',
  fontSize: 14,
  lineNumbers: true,
  wordWrap: true,
  copyButton: true
}

Output Types

  1. Console Output

    console.log('Hello, World!')
  2. Error Output

    throw new Error('Something went wrong')
  3. Formatted Output

    const data = {
      name: 'John',
      age: 30
    }
    console.log(JSON.stringify(data, null, 2))

Advanced Features

Custom Output Formatting

import { registerOutputFormatter } from '@your-package-name'
 
registerOutputFormatter('custom', {
  format: (output) => {
    // Custom formatting logic
    return formattedOutput
  }
})

Output Themes

const customTheme = {
  name: 'output-theme',
  colors: {
    success: '#4CAF50',
    error: '#F44336',
    warning: '#FFC107',
    info: '#2196F3'
  }
}

On this page