Chart Components

Chart frame

Name, size and control a chart with explicit family parts.

Each chart family takes config, an accessible name and explicit children. Config supplies labels and colors; children supply the plotted marks, axes and optional parts.

Usage

import { BarChart, type SeriesConfig } from "@kind-ui/charts";

const config = {
  orders: { label: "Orders", color: "#4477aa" },
} satisfies SeriesConfig;
const data = [{ day: "Mon", orders: 24 }];

<BarChart config={config} data={data} height={280} aria-label="Daily orders">
  <BarChart.XAxis dataKey="day" />
  <BarChart.YAxis />
  <BarChart.Series dataKey="orders" />
  <BarChart.Tooltip />
  <BarChart.Legend />
</BarChart>

Focus Print or Digital to dim its peers while preserving the bars and tooltip values.

Loading chart…

Sizing

Ordinary plots fill the available width and use a 280px height. ActivityRings uses 300px. Set width, height, style or className for your layout; explicit dimensions and inline styles take precedence over the defaults. A percentage height needs a measurable parent. Set responsive={false} when using fixed native chart dimensions.

className, style, native handlers and refs stay on the plot. frameProps supplies attributes, styles, handlers and a ref for the outer HTML frame.

Visibility

Pass visibleSeries to control visibility in your own state. Focus never changes it. To request hide/show from the legend, use visibility interaction and a callback:

import { BarChart } from "@kind-ui/charts";

<BarChart
  config={config} data={data} aria-label="Daily orders"
  interaction={{ kind: "series", mode: "visibility", eligibleKeys: Object.keys(config) }}
  visibleSeries={visibleSeries} onVisibleSeriesChange={setVisibleSeries}
>
  <BarChart.XAxis dataKey="day" />
  <BarChart.Series dataKey="orders" />
  <BarChart.Legend />
</BarChart>

Use defaultVisibleSeries for uncontrolled visibility. Controlled and default values are mutually exclusive. A callback without either value is invalid. Visibility without a callback is read-only.

Legend actions keep at least one eligible item visible. Consumer-controlled visibility can hide every item; provide an empty-result message.

Focus and eligibility

Focus highlights an item without hiding its data. Provide stable eligibleKeys, including hidden and zero-valued identities:

import { BarChart } from "@kind-ui/charts";

<BarChart config={config} data={data} aria-label="Daily orders"
  interaction={{ kind: "series", mode: "focus", eligibleKeys: Object.keys(config) }}
>
  <BarChart.XAxis dataKey="day" />
  <BarChart.Series dataKey="orders" />
  <BarChart.Legend />
</BarChart>

Use selected with onSelectionChange for controlled focus, or defaultSelected for uncontrolled focus. Activating the same item or pressing Escape clears focus. Supported marks share legend actions unless markActivation="none" is set in the interaction options.

Your event handlers run first. Call event.preventDefault() or return false from onBeforeInteraction to cancel a shared action.

Controls and status

Use Content for contextual HTML controls or status text. It mounts outside the SVG while preserving chart context, including through fragments and consumer components. Compound HTML parts mount in the browser.

import { BarChart } from "@kind-ui/charts";

<BarChart config={config} data={data} aria-label="Daily orders">
  <BarChart.XAxis dataKey="day" />
  <BarChart.Series dataKey="orders" />
  <BarChart.Content>
    <p role="status">{data.length} daily observations</p>
  </BarChart.Content>
</BarChart>

children={null} intentionally renders no plot parts.

Props

PropTypeDefaultDescription
noncestring——
visibleSeriesreadonly string[]All registered itemsControlled visibility; provide onVisibleSeriesChange for legend hide/show. Hidden data retains its geometry and dimmed legend/tooltip entries.
defaultVisibleSeriesreadonly string[]All registered itemsInitial uncontrolled visibility; mutually exclusive with visibleSeries. Use explicit visibility interaction for legend hide/show.
onVisibleSeriesChange((next: string[]) => void) | ((next: string[]) => void)——
configReadonly<Record<string, { label?: string; color: SeriesColor; pattern?: FillPattern; icon?: React.ComponentType; legendShape?: NonNullable<React.ComponentProps<typeof Symbols>["type"]>; formatValue?: (value: TooltipValueType) => React.ReactNode; }>>Required—
emphasis"auto" | "none""auto"—
interactionChartInteractionConfigSeries focus; matching-legend marksFocus dims peers by default and supported marks share legend actions. Set mode to "visibility" for visual hide/show with preserved full-data layout, or markActivation to "none" for passive marks. Explicit interaction requires kind and eligibleKeys; selected requires onSelectionChange. Legend actions retain an active item.
aria-labelstring——
aria-labelledbystring——
framePropsOmit<ChartProviderProps, "children" | "config" | "defaultVisibleSeries" | "emphasis" | "interaction" | "nonce" | "onVisibleSeriesChange" | "visibleSeries"> & { [key: `data-${string}`]: unknown; }—Attributes, handlers and ref for the outer HTML frame. Plot props remain on the chart.
childrenstring | number | bigint | boolean | Iterable<React.ReactNode> | Promise<AwaitedReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | nullRequired—

emphasis defaults to "auto". Set "none" to disable Kind emphasis. Bar also supports "category" for safe category comparisons. Each config key supplies a --color-{key} CSS variable for custom marks.

Loading

Set loading while data is pending. Only the plot placeholder is visible; chart-owned legends, content and instructions stay hidden until ready. The chart keeps its size, announces loadingLabel and preserves selection and visibility through loading.

import { LineChart } from "@kind-ui/charts";

<LineChart data={data} config={config} loading={isPending}
  loadingLabel="Loading monthly sales" aria-label="Monthly sales">
  <LineChart.XAxis dataKey="month" />
  <LineChart.Series dataKey="sales" />
  <LineChart.Tooltip />
</LineChart>

Reduced motion keeps the loading preview still. Show your own message for errors or empty results.

PropTypeDefaultDescription
loadingbooleanfalse—
loadingLabelstring"Loading chart"—