CodeBlock.
Code that is as useful as it looks.
Live preview
import { Button } from "luminescent";
import "luminescent/style.css";
<Button>Create project</Button>
import { CodeBlock } from "luminescent";
import "luminescent/style.css";
export function Example() {
return (
<CodeBlock
code={'import { Button } from "luminescent";'}
language="tsx"
showLineNumbers
/>
);
}
Installation
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.
| Prop | Type | Details |
|---|---|---|
code | string | Optional unless marked required. |
language | string | Optional unless marked required. |
lang | string | Optional unless marked required. |
glowVariant | 'peach' | 'comet' | 'light' | Optional unless marked required. |
showLineNumbers | boolean | Optional 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
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.