Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
Data display

Code

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

Frameworks
Astro · React · Elements · Dioxus
Registry
lumen add Code
Interaction
Enhanced runtime
01

See it and copy it

Framework example

Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroCode target · live preview uses Astro

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

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

Wrap prose-like output or long commands when horizontal scrolling would obscure the content.

yaml.github/workflows/validate.yml
name: Lumen checks
on:
  pull_request:
jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - run: pnpm validate

Language colors come from the active Lumen semantic theme tokens without a Shiki setup.

bash
pnpm add @santi020k/lumen-astro

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))";
View Code code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
astro
---
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 appearance="editorial" code={themeExample} recoveryLabel="Select and copy the complete example" copy copyLabel="Copy code" copiedLabel="Copied" label="theme.ts" language="ts" scrollCue variant="block" />

  <p>Wrap prose-like output or long commands when horizontal scrolling would obscure the content.</p>
  <Code
    code={workflowExample}
    copy
    recoveryLabel="Select and copy the complete example"
    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
    recoveryLabel="Select and copy the complete example"
    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>
Edit Code in browser
02

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
bashAstro wrapper
lumen add Code

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
recoveryLabelstring-Opts into a visibly labelled, read-only field with the complete source after clipboard failure. Focusing it selects the text; retrying successfully removes it.
appearance"default" | "editorial""default"Editorial blocks use a code icon and visible localized copy feedback. Both appearances wrap metadata at narrow widths.
variant"inline" | "block""inline"Switches between inline code and a framed code block.
codestring-Renders normalized multiline code with semantic, theme-token-based syntax colors.
languagestring-Labels and highlights JavaScript, TypeScript, JSON, YAML, Bash, Astro/HTML, Markdown, Lua, and SQL families. Unsupported languages remain readable plaintext.
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.
wrapbooleanfalseWraps long block-code lines instead of requiring horizontal scrolling; code blocks also stay within their flex or grid container.
CSS variables--ui-code-dots-displaynoneSet to flex to show window dots in the block header; the default header shows only the filename, language, and copy button.
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.

Customize Code

Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.

cssScoped theme overrides
.product-code {
  --surface: 0 0% 100%;
  --ink: 220 20% 15%;
  --line: 220 15% 82%;
}

Apply product-code through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.

HookValuesDefaultContract
CSS variables--ui-code-dots-displaynoneSet to flex to show window dots in the block header; the default header shows only the filename, language, and copy button.
class, classNamestring""Merges custom classes with the generated ui-* root classes.

Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope


Web docsFull catalog