Code Editor

Lightweight editable code field with syntax highlighting, a filename header, copy and a scoped light/dark toggle.

// Plain markup
import { CodeEditor } from "@shavin/ui";

Interactive Code Editor

Full-featured code input field with scoped dark/light theme switching, filename header, language badge, and real-time line/char counters.

MetricCard.tsxReact TSX
Accessible Radix primitives and semantic tokens supported.12 lines · 430 chars
Full-featured code input field with scoped dark/light theme switching, filename header, language badge, and real-time line/char counters.
import { CodeEditor } from "@shavin/ui";

<CodeEditor
  value={code}
  onChange={setCode}
  filename="MetricCard.tsx"
  language="React TSX"
  allowThemeToggle
/>

Light Theme Scoped Mode

Code editor explicitly set to light theme mode without altering the surrounding platform appearance.

config.tsTypeScript
Accessible Radix primitives and semantic tokens supported.1 line · 60 chars
Code editor explicitly set to light theme mode without altering the surrounding platform appearance.
<CodeEditor
  value={`export const config = { cluster: "us-east-1", replicas: 3 };`}
  theme="light"
  filename="config.ts"
  language="TypeScript"
/>

Read-Only Code Input

Displays immutable code with copy capabilities and custom footer metadata.

Example.tsxReact TSX
Accessible Radix primitives and semantic tokens supported.5 lines · 152 chars
Displays immutable code with copy capabilities and custom footer metadata.
<CodeEditor
  value={`import { Stepper } from "@shavin/ui";`}
  readOnly
  filename="Example.tsx"
/>
PropTypeDefaultDescription
value*string—Source code string to edit or display.
onChange(value: string) => void—Callback fired when code changes.
filenamestring—Filename shown in the top header bar.
languagestring—Language identifier badge (e.g. 'React TSX', 'TypeScript', 'JSON').
showLanguagebooleantrueWhether to show the language badge on the editor header. Default true.
hideHeaderbooleanfalseOption to hide the top header bar completely. Default false.
showHeaderbooleantrueOption to show header (alias for !hideHeader). Default true.
theme"dark" | "light" | "auto"—Scoped theme mode for the editor box: 'dark' | 'light' | 'auto'. In 'auto', defaults to dark IDE theme.
allowThemeToggleboolean—Allow users to toggle between dark and light themes within the editor container.
readOnlyboolean—Whether the code editor is read-only.
placeholderstring—Placeholder text shown when editor is empty.
minHeightnumber | string—Minimum height for the editor in pixels or CSS unit.
copyableboolean—Whether to show a one-click Copy button in the header bar.
headerLeftReactNode—Custom content rendered on the left side of the header bar.
headerRightReactNode—Custom content rendered on the right side of the header bar.
footerReactNode—Custom footer node rendered below the editor.
classNamestring—Custom wrapper class name.
labelstring—Accessible name for the code field. Defaults to the filename.

* required

Configure Theme
Theme
Accent Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font