Loading...
Installation
Usage
import InlineAnalyticsTable from "@/components/ui/inline-analytics-table";
import { TrendingUp, TrendingDown } from "lucide-react";
const analyticsData = [
{ id: "1", region: "North America", sales: 1200, revenue: 25000, growth: 12 },
{ id: "2", region: "Europe", sales: 900, revenue: 18000, growth: -5 },
// ... more data
];
const columns = [
{ key: "region", label: "Region", align: "text-left" },
{ key: "sales", label: "Sales", showProgress: true, progressValue: 70 },
{ key: "revenue", label: "Revenue", showProgress: true, progressValue: 60 },
{ key: "growth", label: "Growth", showProgress: true, progressValue: 50 },
{
key: "growth",
label: "Trend",
align: "text-right",
render: (item) =>
item.growth >= 0 ? (
<TrendingUp className="h-4 w-4 text-green-500" />
) : (
<TrendingDown className="h-4 w-4 text-red-500" />
),
},
];
export default function MyAnalyticsTable() {
return (
<InlineAnalyticsTable
data={analyticsData}
columns={columns}
defaultProgress={50}
/>
);
}
Props
Prop | Type | Default | Description |
---|---|---|---|
data | T[] | defaultData | Array of analytics data items |
columns | ColumnConfig<T>[] | defaultColumns | Column definitions with progress options |
defaultProgress | number | 50 | Default progress value for columns without specific value |
Analytics Item Type
Property | Type | Description |
---|---|---|
id | string | Unique identifier |
region | string | Geographic region or category |
sales | number | Sales figures |
revenue | number | Revenue amount |
growth | number | Growth percentage (can be negative) |
Column Configuration
Property | Type | Description |
---|---|---|
key | keyof T | The data property key this column represents |
label | string | Display label for the column header |
showProgress | boolean | Whether to show progress bar in header |
progressValue | number | Progress bar fill percentage (0-100) |
align | string | Optional CSS text alignment class |
render | (item: T) => React.ReactNode | Custom render function for cell content |
Features
- Header Progress Bars: Visual progress indicators in column headers
- Custom Renderers: Support for custom cell content (icons, badges, etc.)
- Trend Indicators: Built-in trending up/down icons for growth data
- Footer Totals: Automatic calculation and display of totals
- Responsive Design: Horizontal scrolling on smaller screens
- Analytics Focus: Designed specifically for data visualization
- Flexible Columns: Mix of data columns and visual indicator columns
- Professional Styling: Clean, modern appearance suitable for dashboards