Modern React chart library with TypeScript support - Create beautiful, interactive, and accessible data visualizations with ease. Features bar charts, line charts, pie charts, and more!
npm install @kubit-ui-web/react-charts
A modern React charting library
Reusable, accessible, and interactive SVG components for data visualization
---
- Features
- Installation
- Quick Start
- Available Components
- API Reference
- Development Setup
- Project Architecture
- Development Scripts
- Contributing Guidelines
- License
---
> š” Cross-platform: Kubit Charts is also available for Android and iOS platforms, enabling consistent chart experiences across all your applications.
Composable: Modular architecture where each chart is composed of specialized elements
Performant: Optimized SVG rendering with React 18
Accessible: WCAG compliant with keyboard navigation support
Customizable: Flexible styling and granular configurations
Responsive: Adaptable to different screen sizes
TypeScript: Fully typed for better developer experience
SSR Ready: Complete Server-Side Rendering support for Next.js, Remix, Gatsby, and more
Error Handling: Advanced centralized error management system with detailed debugging
Production Safe: Built-in logging system that's automatically optimized for production builds
Tested: Complete coverage with Vitest and Testing Library
``bash`
pnpm add @kubit-ui-web/react-charts
`bash`
npm install @kubit-ui-web/react-charts
`bash`
yarn add @kubit-ui-web/react-charts
This library requires React as a peer dependency:
`bash`
npm install react react-domor
yarn add react react-dom
Compatible versions:
- React: ^18.3.1
- React DOM: ^18.3.1
The library supports granular imports for optimal bundle size:
`typescript`
// Import specific charts only
import { BarChart } from '@kubit-ui-web/react-charts/charts/barChart';
import { LineChart } from '@kubit-ui-web/react-charts/charts/lineChart';
// Import specific components only
import { Node } from '@kubit-ui-web/react-charts/components/node';
import { Path } from '@kubit-ui-web/react-charts/components/path';
// Import specific utilities only
import { logger } from '@kubit-ui-web/react-charts/utils/logger';
import { isBrowser } from '@kubit-ui-web/react-charts/utils/ssr';
`typescript`
// Import complete charts
import { BarChart, LineChart, PieChart } from '@kubit-ui-web/react-charts';
// Import specific components
import { Node, Path, Plot } from '@kubit-ui-web/react-charts/components';
// Import types
import type { BarOrientation, ChartData } from '@kubit-ui-web/react-charts/types';
// Import utilities
import { configureLogger, logger } from '@kubit-ui-web/react-charts/utils';
import { createSVGElement, isBrowser, safeWindow } from '@kubit-ui-web/react-charts/utils';
`tsx
import { LineChart } from '@kubit-ui-web/react-charts';
import React from 'react';
const data = [
{ year: '2020', sales: 100, profit: 20 },
{ year: '2021', sales: 150, profit: 35 },
{ year: '2022', sales: 180, profit: 45 },
{ year: '2023', sales: 200, profit: 60 },
];
function MyLineChart() {
return (
} />
);
}
`
`tsx
import { BarChart, BarOrientation } from '@kubit-ui-web/react-charts';
import React from 'react';
const data = [
{ category: 'A', value: 30 },
{ category: 'B', value: 45 },
{ category: 'C', value: 25 },
{ category: 'D', value: 60 },
];
function MyBarChart() {
return (
pKey="category"
orientation={BarOrientation.VERTICAL}
gapBetweenBars={5}
width="100%"
height="400px"
>
dataIdx={0}
barConfig={{
barWidth: 40,
singleConfig: [{ color: '#0078D4', coverage: 100 }],
}}
/>
);
}
`
`tsx
import { LineChart } from '@kubit-ui-web/react-charts';
import type { ChartErrorCollection } from '@kubit-ui-web/react-charts/types';
import React from 'react';
function ChartWithErrorHandling() {
const handleErrors = (errors: ChartErrorCollection) => {
// Centralized error handling
console.warn('Chart errors:', errors);
// Display user-friendly messages or retry logic
};
return (
);
}
`
`tsx
import { LineChart, isBrowser, safeWindow } from '@kubit-ui-web/react-charts';
import React from 'react';
function SSRCompatibleChart() {
// Safe browser API access
const windowWidth = isBrowser() ? safeWindow()?.innerWidth || 800 : 800;
return (
);
}
`
`tsx
import { configureLogger, logger } from '@kubit-ui-web/react-charts';
// Configure logger for development
configureLogger({
enabled: true,
minLevel: 'debug',
prefix: '[MyApp Charts]',
});
// Use logger in your components
function MyComponent() {
logger.info('Chart rendering started');
// Chart implementation
}
`
| Component | Description | Use Cases |
| --------------- | ----------------------------- | ----------------------------------- |
| LineChart | Multi-series line chart | Time trends, metric comparisons |
| BarChart | Horizontal/vertical bar chart | Category comparisons, discrete data |
| PieChart | Circular chart with segments | Part-to-whole relationships |
| Component | Description |
| --------------- | ----------------------------- |
| Plot | Base SVG container for charts |
| Path | Customizable SVG path element |
| Node | Interactive points in charts |
| Line | Lines and connectors |
| Bar | Rectangular bars |
| ChartText | Formatted text for labels |
| Hook | Description |
| -------------- | ---------------------------------------- |
| useFocus | Focus state management for accessibility |
| useHover | Hover detection with callbacks |
| Utility | Description |
| ---------------------------- | -------------------------------------------------- |
| logger | Production-safe logging with configurable levels |
| configureLogger | Logger configuration for development/debugging |
| isBrowser | Environment detection for browser vs SSR |
| isServer | Check if running in server-side environment |
| safeWindow | Safe access to window object in SSR environments |
| safeDocument | Safe access to document object in SSR environments |
| createSVGElement | SSR-compatible SVG element creation |
| createErrorAccumulator | Advanced error management for chart components |
For detailed API documentation, component props, and advanced examples, please refer to our individual component READMEs:
- BarChart Documentation
- LineChart Documentation
- PieChart Documentation
---

- Node.js >= 16
- Yarn (recommended) or npm
- Git
1. Clone the repository
`bash`
git clone https://github.com/kubit-ui/kubit-react-charts
cd web-ui-charts/app
2. Install dependencies
`bash`
yarn install
3. Start development server
`bash`
yarn start
This will launch Storybook at http://localhost:6006 where you can interact with all components.
``
src/
āāā charts/ # High-level chart components
ā āāā barChart/ # BarChart and subcomponents
ā āāā lineChart/ # LineChart and subcomponents
ā āāā pieChart/ # PieChart and subcomponents
āāā components/ # Reusable SVG base components
ā āāā plot/ # Main SVG container
ā āāā path/ # Path elements
ā āāā node/ # Interactive points
ā āāā line/ # Lines and connectors
ā āāā ...
āāā hooks/ # Custom hooks
āāā types/ # TypeScript definitions
āāā utils/ # Shared utility functions
āāā storybook/ # Storybook configuration and constants
Each chart follows a consistent compositional pattern:
`typescript`
const LineChart = Object.assign(LineChartStructure, {
Path: LineChartPath,
XAxis: LineChartXAxis,
YAxis: LineChartYAxis,
Separator: LineChartSeparator,
});
This pattern enables:
- Flexibility: Use only the components you need
- Reusability: Shared components between different charts
- Extensibility: Easy addition of new subcomponents
`bashStart Storybook in development mode
pnpm start
$3
`bash
Complete build (ESM + CJS)
yarn distBuild in watch mode
yarn dist:watchCommonJS only
yarn dist:cjsES Modules only
yarn dist:esm
`$3
`bash
Unit tests with UI
yarn vitest-reportStorybook tests
yarn test-storybookESLint only
yarn eslint --fix
``- TypeScript: Fully typed code
- ESLint: Strict configuration with Kubit rules
- Prettier: Automatic code formatting
- Testing: Minimum 80% coverage
See our CONTRIBUTING for coding conventions, commit message guidelines, and pull request processes.
Please refer to our development instructions for detailed guidelines on:
- Component structure and patterns
- Naming conventions
- TypeScript usage
- Error handling
- CSS and styling
- Accessibility requirements
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
---
Made with ā¤ļø by the Kubit team ![]()