Code
Renders inline code and framed code blocks with theme-aware palettes.
See it and copy it
Framework example
Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.
Apply the current theme with data-theme on the root element.
const theme = "lumen";
const accent = "hsl(var(--accent))";Wrap prose-like output or long commands when horizontal scrolling would obscure the content.
name: Lumen checks
on:
pull_request:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- run: pnpm validateLanguage colors come from the active Lumen semantic theme tokens without a Shiki setup.
pnpm add @santi020k/lumen-astroOverride the syntax palette family with theme.
const theme = "lumen";
const accent = "hsl(var(--accent))";const theme = "lumen";
const accent = "hsl(var(--accent))";Framework usage
Switch targets to compare the adapter code. The preview stays visually stable because all three packages share the same tokens andui-* class contract.---
import { Code } from '@santi020k/lumen-astro'
const themeExample = `
const theme = "lumen";
const accent = "hsl(var(--accent))";
`
const workflowExample = `
name: Lumen checks
on:
pull_request:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- run: pnpm validate
`
---
<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>Wrap prose-like output or long commands when horizontal scrolling would obscure the content.</p>
<Code
code={workflowExample}
copy
label=".github/workflows/validate.yml"
language="yaml"
variant="block"
wrap
/>
<p>Language colors come from the active Lumen semantic theme tokens without a Shiki setup.</p>
<Code
code="pnpm add @santi020k/lumen-astro"
copy
language="bash"
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-react'
const themeExample = `
const theme = "lumen";
const accent = "hsl(var(--accent))";
`
export const Example = () => (
<Code code={themeExample} copy label="theme.ts" language="ts" variant="block" />
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-code data-code-theme="auto" variant="block">
<figcaption class="ui-code__header">
<span class="ui-code__dots" aria-hidden="true">
<span class="ui-code__dot ui-code__dot--red"></span>
<span class="ui-code__dot ui-code__dot--yellow"></span>
<span class="ui-code__dot ui-code__dot--green"></span>
</span>
<span class="ui-code__meta">
<span class="ui-code__language">ts</span>
<span class="ui-code__label">theme.ts</span>
</span>
</figcaption>
<pre><code>const theme = "lumen";
const accent = "hsl(var(--accent))";</code></pre>
</lumen-code>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.
pnpm add @santi020k/lumen-astropnpm add @santi020k/lumen-astrolumen add Codelumen add Codepnpm add @santi020k/lumen-reactpnpm add @santi020k/lumen-reactlumen add Code --target reactlumen add Code --target reactpnpm add @santi020k/lumen-elementspnpm add @santi020k/lumen-elementslumen add Code --target elementslumen add Code --target elementsAPI 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.
| Attribute | Values | Default | Description |
|---|---|---|---|
| variant | "inline" | "block" | "inline" | Switches between inline code and a framed code block. |
| code | string | - | Renders normalized multiline code with semantic, theme-token-based syntax colors. |
| language | string | - | Labels and highlights JavaScript, TypeScript, JSON, YAML, Bash, Astro/HTML, Markdown, Lua, and SQL families. Unsupported languages remain readable plaintext. |
| label | string | - | Adds a compact filename or title to the block header. |
| copy | boolean | false | Shows a copy button when UIPrimitives is mounted. |
| highlighted | boolean | false | Allows a pre-highlighted pre/code tree, such as Shiki output, to render directly. |
| theme | "auto" | "lumen" | "santi020k" | "auto" | Selects the code palette family. |
| wrap | boolean | false | Wraps long block-code lines instead of requiring horizontal scrolling; code blocks also stay within their flex or grid container. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |