121
GitHub
Data display

Code

Renders inline code and framed code blocks with theme-aware palettes.

FrameworksAstro · React · Elements

Registry commandlumen add Code

InteractionEnhanced runtime

01

See it in context

Preview

Apply the current theme with data-theme on the root element.

tstheme.ts
const theme = "lumen";
const accent = "hsl(var(--accent))";

Override the syntax palette family with theme.

tslumen
const theme = "lumen";
const accent = "hsl(var(--accent))";
tssanti020k
const theme = "lumen";
const accent = "hsl(var(--accent))";
02

Copy a working example

Usage

Astro examples assume UIPrimitives is mounted once in your root layout. Do not add the runtime next to each component instance.

astro
---
import { Code } from '@santi020k/lumen-astro'

const themeExample = `
  const theme = "lumen";
  const accent = "hsl(var(--accent))";
`
---

<div class="grid gap-4">
  <p>Apply the current theme with <Code>data-theme</Code> on the root element.</p>
  <Code code={themeExample} copy label="theme.ts" language="ts" variant="block" />
  
  <p>Override the syntax palette family with <Code>theme</Code>.</p>
  <Code code={themeExample} label="lumen" language="ts" theme="lumen" variant="block" />
  <Code code={themeExample} label="santi020k" language="ts" theme="santi020k" variant="block" />
</div>
---
import { Code } from '@santi020k/lumen-astro'

const themeExample = `
  const theme = "lumen";
  const accent = "hsl(var(--accent))";
`
---

<div class="grid gap-4">
  <p>Apply the current theme with <Code>data-theme</Code> on the root element.</p>
  <Code code={themeExample} copy label="theme.ts" language="ts" variant="block" />
  
  <p>Override the syntax palette family with <Code>theme</Code>.</p>
  <Code code={themeExample} label="lumen" language="ts" theme="lumen" variant="block" />
  <Code code={themeExample} label="santi020k" language="ts" theme="santi020k" variant="block" />
</div>
03

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add Code
lumen add Code

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
variant"inline" | "block""inline"Switches between inline code and a framed code block.
codestring-Renders a normalized multiline code string with lightweight token colors.
languagestring-Labels the code language in block headers.
labelstring-Adds a compact filename or title to the block header.
copybooleanfalseShows a copy button when UIPrimitives is mounted.
highlightedbooleanfalseAllows a pre-highlighted pre/code tree, such as Shiki output, to render directly.
theme"auto" | "lumen" | "santi020k""auto"Selects the code palette family.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.