Code Editor

// 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*stringSource code string to edit or display.
onChange(value: string) => voidCallback fired when code changes.
filenamestringFilename shown in the top header bar.
languagestringLanguage 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.
allowThemeTogglebooleanAllow users to toggle between dark and light themes within the editor container.
readOnlybooleanWhether the code editor is read-only.
placeholderstringPlaceholder text shown when editor is empty.
minHeightnumber | stringMinimum height for the editor in pixels or CSS unit.
copyablebooleanWhether to show a one-click Copy button in the header bar.
headerLeftReactNodeCustom content rendered on the left side of the header bar.
headerRightReactNodeCustom content rendered on the right side of the header bar.
footerReactNodeCustom footer node rendered below the editor.
classNamestringCustom wrapper class name.

* required

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