Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
Data displayGlass surface

Chart

Frames metric headers, SVG plots, and captions for lightweight data visualization.

Frameworks
Astro · React · Elements · Dioxus
Registry
lumen add Chart
Interaction
Native markup
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

Revenue

Last five quarters

$128.4K
Revenue is up 42% since Q1 after a temporary Q4 dip.
View Chart 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 { Chart } from '@santi020k/lumen-astro'
---

<Chart aria-labelledby="chart-revenue-title">
  <header>
    <div>
      <h3 id="chart-revenue-title">Revenue</h3>
      <p>Last five quarters</p>
    </div>
    <strong data-ui-chart-value>$128.4K</strong>
  </header>
  <svg viewBox="-3 -3 126 46" role="img" aria-label="Revenue trend">
    <defs>
      <linearGradient id="chart-revenue-fill" x1="0" x2="0" y1="0" y2="1">
        <stop offset="0%" stop-color="currentColor" stop-opacity="0.22" />
        <stop offset="100%" stop-color="currentColor" stop-opacity="0" />
      </linearGradient>
    </defs>
    <path d="M0 35 L30 26 L60 18 L90 22 L120 8 L120 40 L0 40 Z" fill="url(#chart-revenue-fill)" />
    <path d="M0 35 L30 26 L60 18 L90 22 L120 8" fill="none" stroke="currentColor" stroke-width="2.5" />
    <g fill="currentColor">
      <circle cx="0" cy="35" r="1.1" />
      <circle cx="30" cy="26" r="1.1" />
      <circle cx="60" cy="18" r="1.1" />
      <circle cx="90" cy="22" r="1.1" />
      <circle cx="120" cy="8" r="1.1" />
    </g>
  </svg>
  <figcaption>Revenue is up 42% since Q1 after a temporary Q4 dip.</figcaption>
</Chart>
Edit Chart 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 Chart

Glass

Add the glass prop to apply the shared blur, saturation, border, and highlight tokens. Glass reads best over vivid content, so place the surface above imagery or color.

AstroCode target · live preview uses Astro

Coverage

94%+6 pts
Glass support is available across surface primitives.
View Chart 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 and Elements use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
astro
---
import { Badge, Chart } from '@santi020k/lumen-astro'
---

<div class="docs-glass-demo">
  <Chart aria-label="Glass adoption" glass>
    <header>
      <h3>Coverage</h3>
      <strong data-ui-chart-value>94%</strong>
      <Badge variant="success">+6 pts</Badge>
    </header>
    <svg viewBox="0 0 120 40" role="img" aria-label="Coverage trend">
      <path d="M0 34 L24 28 L48 22 L72 18 L96 12 L120 7" fill="none" stroke="currentColor" stroke-width="3" />
    </svg>
    <figcaption>Glass support is available across surface primitives.</figcaption>
  </Chart>
</div>
Edit Chart in browser

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
glassboolean | "subtle" | "strong"falseApplies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity.
presentation"default" | "bare""default"Removes the frame, background, shadow, and padding when a chart is composed inside Card.
childrencustom SVG, canvas, HTML plot, and optional tablerequiredComposes a specialized visualization while the consumer owns its data and accessible description.
heading, description, valuestring-Builds the standard visible chart header without consuming the native title attribute.
captionstring-Adds a semantic figcaption after the custom plot.
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 Chart

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-chart {
  --surface: 0 0% 100%;
  --ink: 220 20% 15%;
  --line: 220 15% 82%;
}

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

HookValuesDefaultContract
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