Command Palette

Search for a command to run...

Docs
Inline Analytics Table

Inline Analytics Table

A data table component with built-in analytics visualization including progress bars in headers and trend indicators.

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

PropTypeDefaultDescription
dataT[]defaultDataArray of analytics data items
columnsColumnConfig<T>[]defaultColumnsColumn definitions with progress options
defaultProgressnumber50Default progress value for columns without specific value

Analytics Item Type

PropertyTypeDescription
idstringUnique identifier
regionstringGeographic region or category
salesnumberSales figures
revenuenumberRevenue amount
growthnumberGrowth percentage (can be negative)

Column Configuration

PropertyTypeDescription
keykeyof TThe data property key this column represents
labelstringDisplay label for the column header
showProgressbooleanWhether to show progress bar in header
progressValuenumberProgress bar fill percentage (0-100)
alignstringOptional CSS text alignment class
render(item: T) => React.ReactNodeCustom 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