Join our Discord community
Code

Code Editor

Animated code editor component for React and Next.js applications. Built with TypeScript support, Tailwind CSS styling, and shadcn/ui design featuring syntax highlighting, typing animations, and customizable themes.

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/code-editor.json
npx shadcn@latest add https://www.shadcn.io/registry/code-editor.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/code-editor.json
bunx shadcn@latest add https://www.shadcn.io/registry/code-editor.json

Features

  • Syntax highlighting - Multi-language support with Shiki integration using JavaScript parsing
  • Typing animations - Realistic code writing simulation with configurable speed using Motion library
  • Theme switching - Light/dark mode support with next-themes integration for React applications
  • Copy functionality - Built-in copy button with custom callback support using TypeScript handlers
  • Viewport detection - InView animations with configurable margins for Next.js projects
  • Customizable header - macOS-style window with dots, title, and icon support using Tailwind CSS
  • Cursor animation - Blinking cursor effect during typing simulation using CSS animations
  • Open source - Free code editor component with shadcn/ui theming and accessibility features

Examples

With Custom Theme

Loading component...

No Writing Animation

Loading component...

Use Cases

  • Documentation sites - Code examples with syntax highlighting and copy functionality
  • Tutorial platforms - Step-by-step coding demonstrations with typing effects
  • Portfolio showcases - Interactive code displays for developer presentations
  • Demo applications - Code snippet previews with realistic animation timing

API Reference

CodeEditor

PropTypeDefaultDescription
childrenstringrequiredThe code content to display and animate
langstringrequiredProgramming language for syntax highlighting
themes{ light: string; dark: string }{ light: 'github-light', dark: 'github-dark' }Shiki theme names for light and dark modes
durationnumber5Animation duration in seconds for typing effect
delaynumber0Delay before animation starts in seconds
headerbooleantrueShow macOS-style header with traffic lights
dotsbooleantrueShow colored dots in header (red, yellow, green)
iconReact.ReactNodeundefinedIcon to display next to title in header
cursorbooleanfalseShow blinking cursor during typing animation
inViewbooleanfalseOnly animate when component is in viewport
inViewMarginstring'0px'Margin for viewport detection
inViewOncebooleantrueAnimate only once when entering viewport
copyButtonbooleanfalseShow copy to clipboard button
writingbooleantrueEnable typing animation effect
titlestringundefinedTitle text to display in header
onDone() => voidundefinedCallback when typing animation completes
onCopy(content: string) => voidundefinedCallback when copy button is clicked

Implementation

Built with Shiki for syntax highlighting and Motion for animations. Uses next-themes for theme detection. Supports custom languages and themes. InView detection with configurable animation triggers.