Editor Code Codemirror
Light code editor with a language switcher for TypeScript, JSON, CSS, Markdown and Python.
Choose the primitives library your project already uses. Both look the same: your theme, not the variant, controls colors, shape, type and motion.
About this block
What it's for
- Light code editor with a language switcher for TypeScript, JSON, CSS, Markdown and Python.
- CodeMirror 6 editor in React with read-only mode and a diff gutter showing changed lines.
- Inline editor for config files, snippets or prompts with syntax highlighting that follows the theme.
For a read-only side by side diff between two files, use Code Diff Viewer. For showing code on a marketing page without editing, use Marketing Code Showcase. For rich text with formatting, use Editor Rich Text Tiptap.
Includes
- Code editing
- Codemirror
- Language switch
- Syntax highlighting
- Read only mode
- Diff gutter
- Line numbers
- Token theme
Works with
- Radix UI and Base UI primitives (pick the one your project uses)
- React 19 and Tailwind CSS 4 in Next.js (App Router), Vite, React Router or TanStack Start, installed with the agentic-ui or shadcn CLI
- Your theme tokens, in light and dark mode
Install
Included with Agentic UI Kit (one-time license). Install needs your license key: see pricing · connect your project.
agentic-ui add editor-code-codemirrornpx shadcn@4.17.0 add @agentic-ui/editor-code-codemirrorUsed in
A standalone component: drop it into any screen.
- Type
- Block
- Variants
- Radix UI and Base UI
- Themes
- Light and dark
- Widths
- Preview it at desktop, tablet and mobile widths above.
- Sample data
- Ships with sample data in
code-samples.ts; replace it with your own.
- npm packages
@codemirror/commands@codemirror/lang-css@codemirror/lang-javascript@codemirror/lang-json@codemirror/lang-markdown@codemirror/lang-python@codemirror/language@codemirror/state@codemirror/view@lezer/highlightlucide-react- Registry dependencies
lib-primitives- Files
6 files
- components/agentic-ui/editor-code-codemirror/editor-code-codemirror/editor-code-codemirror.tsx
- components/agentic-ui/editor-code-codemirror/editor-code-codemirror/use-codemirror.ts
- components/agentic-ui/editor-code-codemirror/editor-code-codemirror/diff-model.ts
- components/agentic-ui/editor-code-codemirror/editor-code-codemirror/cm-theme.ts
- components/agentic-ui/editor-code-codemirror/editor-code-codemirror/cm-diff-gutter.ts
- components/agentic-ui/editor-code-codemirror/editor-code-codemirror/code-samples.ts
Related components
Editor Rich Text Tiptap
Rich text editor with a toolbar, slash commands and mentions for notes, comments or documents.
Details and live previewA11y Contrast Badge
Check in the browser whether the theme palette meets AA before opening the PR.
Details and live previewA11y Focus Manager
Confirmation dialog that returns focus to the button that opened it.
Details and live previewA11y Live Announcer
Announce the number of results when filtering a table without reloading the page.
Details and live preview