Data display

CodeBlock.

Code that is as useful as it looks.

Live preview

Live preview
tsx
import { Button } from "luminescent";
import "luminescent/style.css";


<Button>Create project</Button>
tsx
import { CodeBlock } from "luminescent";
import "luminescent/style.css";


export function Example() {
  return (
    <CodeBlock
      code={'import { Button } from "luminescent";'}
      language="tsx"
      showLineNumbers
    />
  );
}

Installation

bash
npm install luminescent

Import luminescent/style.css once at your application root. The example above uses the same package implementation as Storybook.

Variants and states

Use the preview controls to explore the supported variants, sizes, disabled/loading states and reduced motion. Controls appear only where the component exposes the corresponding prop. Theme and glow apply to every component.

API reference

Generated from the source TypeScript interfaces. Native attributes, className, style, aria-* and data-* also pass through to the documented element. Import CodeBlockProps from the package for the full inherited contract.

PropTypeDetails
codestringOptional unless marked required.
languagestringOptional unless marked required.
langstringOptional unless marked required.
glowVariant'peach' | 'comet' | 'light'Optional unless marked required.
showLineNumbersbooleanOptional unless marked required.

Accessibility and keyboard

Scrollable keyboard-focusable code region. Copy reports success/failure in a status region, preserves the original source, and never includes decorative line numbers. Unknown languages and sources over 20,000 characters render as plain text.

Keep labels meaningful and test application-level contrast, focus order and screen-reader output. See the accessibility guide for composition requirements.

Theme customization

tsx
import { LuminescentProvider, CodeBlock } from "luminescent";
import "luminescent/style.css";


export function Example() {
  return (
    <LuminescentProvider theme="light" accent="violet" glow="subtle">
      <CodeBlock
        code={'import { LuminescentProvider, Button } from "luminescent";'}
        language="tsx"
        showLineNumbers
      />
    </LuminescentProvider>
  );
}

Switch between light and dark in the preview, or open the playground for a larger workspace. Custom CSS variables can override spacing, color, typography and effects.

Related components