Veil UI
Components

Chart

A responsive chart shell with shared config, tooltip and legend content.

Installation

$ npx veil-ui@latest add chart

Usage

import { Bar, BarChart, XAxis } from "recharts";

import { ChartContainer, ChartTooltip } from "@/components/ui/chart";

const config = { revenue: { label: "Revenue", color: "#6366f1" } };

<ChartContainer config={config} height={300}>
  <BarChart data={data}>
    <XAxis dataKey="month" />
    <ChartTooltip />
    <Bar dataKey="revenue" fill="#6366f1" />
  </BarChart>
</ChartContainer>;

Examples

Basic

Compact

API reference

The package exports chart along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Charts render inside a container with an explicit height so they stay responsive without layout shift.
  • Color is never the only encoding; pair charts with labels, summaries or a data table for critical information.
  • Tooltips and legends are rendered as HTML, so their text is available to assistive technology.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add chart --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { computed } from "vue";

import { cn } from "@/lib/utils";

import { provideChartConfig } from "./use-chart";
import type { ChartConfig } from "./variants";

const props = withDefaults(
  defineProps<{
    config: ChartConfig;
    height?: number;
    class?: string;
  }>(),
  { height: 300 },
);

provideChartConfig(props.config);

const style = computed(() => ({ height: `${props.height}px` }));
</script>

<template>
  <div data-slot="chart" :class="cn('w-full', props.class)" :style="style">
    <slot />
  </div>
</template>

On this page