UI Components Architecture
Overview
Claude Code's UI is built with Ink - a React renderer for terminals. It provides a component-based architecture similar to web React, but outputting to the terminal instead of the DOM.
┌─────────────────────────────────────────────────────────────────────────────┐
│ UI ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ REACT + INK STACK │ │
│ │ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ React │───►│ Ink │───►│ Yoga │───►│ ANSI │ │ │
│ │ │Components│ │Renderer │ │Layout │ │Output │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
│ │ │ │ │ │ │ │
│ │ ▼ ▼ ▼ ▼ │ │
│ │ JSX/TSX Reconciler Flexbox Terminal │ │
│ │ Components (diffing) Layout Escape Codes │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ COMPONENT HIERARCHY │ │
│ │ │ │
│ │ ┌──────────┐ │ │
│ │ │ App │ │ │
│ │ └────┬─────┘ │ │
│ │ │ │ │
│ │ ┌───────────────┼───────────────┐ │ │
│ │ ▼ ▼ ▼ │ │
│ │ ┌────────┐ ┌────────┐ ┌────────────┐ │ │
│ │ │ REPL │ │ Dialogs│ │ Fullscreen │ │ │
│ │ │ │ │ │ │ Layouts │ │ │
│ │ └───┬────┘ └────────┘ └────────────┘ │ │
│ │ │ │ │
│ │ ┌───────┴───────┐ │ │
│ │ ▼ ▼ │ │
│ │ ┌────────┐ ┌──────────┐ │ │
│ │ │Prompt │ │ Messages │ │ │
│ │ │Input │ │ Panel │ │ │
│ │ └────┬───┘ └────┬─────┘ │ │
│ │ │ │ │ │
│ │ ▼ ▼ │ │
│ │ TextInput MessageList │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘