Data

Chart.

Readable series, exact values and smooth exploration across line, bar and area views.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/chart.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Series with exact values

Explicit categories and missing values are inspectable as both a chart and a data table.

Loads this example when you need it.

Keyboard

  • Arrow keys inspect point values.
  • Legend buttons change visible series; Show data opens the exact table.

States covered

  • Line or bar
  • Missing point
  • Series visibility

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-chart.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {Button,Chart,type ChartDatum,type ChartSeries,type ChartType} from '@bld8/ui';
import '@bld8/ui/styles.css';
const data:ChartDatum[]=[{id:'mon',label:'Mon',values:{done:12,review:4}},{id:'tue',label:'Tue',values:{done:18,review:null}},{id:'wed',label:'Wed',values:{done:15,review:6}}];
const series:ChartSeries[]=[{id:'done',label:'Completed',tone:'primary'},{id:'review',label:'In review',tone:'accent'}];
export default function ChartExample(){const [type,setType]=useState<ChartType>('line');return <div><Button variant="secondary" onClick={()=>setType(type==='line'?'bar':'line')}>Switch example chart type</Button><Chart label="Example review counts" description="Illustrative local counts, with one missing observation." data={data} series={series} type={type}/></div>;}

Quick reference

React / TypeScript
<Chart label="Weekly requests" data={data}
  series={[
    {id:"completed",label:"Completed",tone:"primary"},
    {id:"failed",label:"Failed",tone:"accent"}
  ]} type="line" />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Labelled categories contain a values object with a finite number or null for every named series. Null means missing data; line and area paths do not connect across gaps. Signed values retain a zero baseline. One shared axis means series should use the same unit. Legends change visible series, point buttons provide arrow/Home/End exploration, and a stable readout shows the active values. Show data exposes an exact table of all original series. Colour is accompanied by patterns and text. Data is bounded to 366 categories and six series; evenly spaced categories are supplied display labels, not parsed dates. Geometry, validation and summaries are exported from the pure chart-state module. Smooth motion responds to live reduced-motion changes.

Chart

Chart public properties
PropTypeDefault
dataRequiredreadonly ChartDatum[]—
labelRequiredstring—
seriesRequiredreadonly ChartSeries[]—
classNamestring | undefined—
descriptionstring | undefined—
heightnumber | undefined

Plot height in CSS pixels, clamped to 160–480.

240
typeChartType | undefined'line'
valueFormatter((value: number) => string) | undefined—

ChartDatum

ChartDatum public properties
PropTypeDefault
idRequiredstring—
labelRequiredstring—
valuesRequiredReadonly<Record<string, number | null>>

An explicit number or null for every series. Null leaves a gap.

—

ChartSeries

ChartSeries public properties
PropTypeDefault
idRequiredstring—
labelRequiredstring—
tone"primary" | "accent" | "muted" | undefined

Preferred shade in the theme's data palette; repeated tones use distinct slots.

—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.