Financial Table
Data Display
Tables
Data table optimized for financial data with currency formatting, sorting, negative highlighting, and totals.
Preview
Click column headers to sort
Region | Q1(USD) | Q2(USD) | Q3(USD) | Q4(USD) |
|---|---|---|---|---|
| North America | 125,000.00 | 142,000.00 | 138,000.00 | 165,000.00 |
| Europe | 98,000.00 | 105,000.00 | 112,000.00 | 128,000.00 |
| Asia Pacific | 87,000.00 | 92,000.00 | 99,000.00 | 115,000.00 |
| Latin America | 45,000.00 | 48,000.00 | 52,000.00 | 58,000.00 |
With Totals Row
Automatic sum calculation for numeric columns
Region | Q1(USD) | Q2(USD) | Q3(USD) | Q4(USD) |
|---|---|---|---|---|
| North America | 125,000.00 | 142,000.00 | 138,000.00 | 165,000.00 |
| Europe | 98,000.00 | 105,000.00 | 112,000.00 | 128,000.00 |
| Asia Pacific | 87,000.00 | 92,000.00 | 99,000.00 | 115,000.00 |
| Latin America | 45,000.00 | 48,000.00 | 52,000.00 | 58,000.00 |
| Grand Total | 355,000.00 | 387,000.00 | 401,000.00 | 466,000.00 |
Negative Value Highlighting
Negative numbers are automatically highlighted in red
Category | Revenue(USD) | Expenses(USD) | Net Profit(USD) |
|---|---|---|---|
| Product Sales | 520,000.00 | 312,000.00 | 208,000.00 |
| Services | 180,000.00 | 125,000.00 | 55,000.00 |
| Licensing | 95,000.00 | 12,000.00 | 83,000.00 |
| Subscriptions | 210,000.00 | 145,000.00 | 65,000.00 |
| Returns & Refunds | -35,000.00 | 8,000.00 | -43,000.00 |
| Total | 970,000.00 | 602,000.00 | 368,000.00 |
Density Options
Compact, comfortable, or spacious row padding
Compact
Region | Q1(USD) | Q2(USD) | Q3(USD) | Q4(USD) |
|---|---|---|---|---|
| North America | 125,000.00 | 142,000.00 | 138,000.00 | 165,000.00 |
| Europe | 98,000.00 | 105,000.00 | 112,000.00 | 128,000.00 |
Comfortable (default)
Region | Q1(USD) | Q2(USD) | Q3(USD) | Q4(USD) |
|---|---|---|---|---|
| North America | 125,000.00 | 142,000.00 | 138,000.00 | 165,000.00 |
| Europe | 98,000.00 | 105,000.00 | 112,000.00 | 128,000.00 |
Spacious
Region | Q1(USD) | Q2(USD) | Q3(USD) | Q4(USD) |
|---|---|---|---|---|
| North America | 125,000.00 | 142,000.00 | 138,000.00 | 165,000.00 |
| Europe | 98,000.00 | 105,000.00 | 112,000.00 | 128,000.00 |
Striped Rows
Alternating row backgrounds for better readability
Region | Q1(USD) | Q2(USD) | Q3(USD) | Q4(USD) |
|---|---|---|---|---|
| North America | 125,000.00 | 142,000.00 | 138,000.00 | 165,000.00 |
| Europe | 98,000.00 | 105,000.00 | 112,000.00 | 128,000.00 |
| Asia Pacific | 87,000.00 | 92,000.00 | 99,000.00 | 115,000.00 |
| Latin America | 45,000.00 | 48,000.00 | 52,000.00 | 58,000.00 |
| Total | 355,000.00 | 387,000.00 | 401,000.00 | 466,000.00 |
Custom Number Formatting
Use format function for custom number display
Region | Q1 Revenue | Q2 Revenue | Q3 Revenue | Q4 Revenue |
|---|---|---|---|---|
| North America | $125K | $142K | $138K | $165K |
| Europe | $98K | $105K | $112K | $128K |
| Asia Pacific | $87K | $92K | $99K | $115K |
| Latin America | $45K | $48K | $52K | $58K |
| Total | $355K | $387K | $401K | $466K |
Props
FinancialTable component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
columns | FinancialColumn[] | — | Column definitions (required) |
data | T[] | — | Array of row data objects (required) |
striped | boolean | false | Alternate row backgrounds |
highlightNegative | boolean | true | Highlight negative numbers in red |
showTotals | boolean | false | Show totals footer row |
totalsLabel | string | 'Total' | Label for totals row |
density | 'compact' | 'comfortable' | 'spacious' | 'comfortable' | Row padding |
className | string | — | Additional CSS classes |
FinancialColumn Type
| Prop | Type | Default | Description |
|---|---|---|---|
key | string | — | Property key in data object (required) |
label | string | — | Column header text (required) |
currency | string | — | Currency code to display (e.g., "USD") |
decimals | number | 2 | Decimal places |
sortable | boolean | false | Enable column sorting |
width | string | — | CSS width value |
align | 'left' | 'right' | 'right' | Text alignment |
format | (value: number) => string | — | Custom number formatter |
render | (value, row) => ReactNode | — | Custom cell render |
Usage
Import and implementation example
import { FinancialTable, FinancialColumn } from '@/blocks/data-display/financial-table'
interface SalesData {
region: string
revenue: number
profit: number
}
const columns: FinancialColumn<SalesData>[] = [
{ key: 'region', label: 'Region', align: 'left' },
{ key: 'revenue', label: 'Revenue', currency: 'USD', sortable: true },
{ key: 'profit', label: 'Profit', currency: 'USD', sortable: true },
]
const data: SalesData[] = [
{ region: 'North America', revenue: 125000, profit: 45000 },
{ region: 'Europe', revenue: 98000, profit: 32000 },
]
export default function Example() {
return (
<>
{/* Basic table */}
<FinancialTable columns={columns} data={data} />
{/* With totals row */}
<FinancialTable
columns={columns}
data={data}
showTotals
totalsLabel="Total"
/>
{/* Highlight negative values */}
<FinancialTable
columns={columns}
data={data}
highlightNegative
/>
{/* Custom number formatting */}
<FinancialTable
columns={[
{ key: 'revenue', label: 'Revenue', format: (v) => `$${(v / 1000).toFixed(0)}K` },
]}
data={data}
/>
{/* Different densities */}
<FinancialTable columns={columns} data={data} density="compact" />
<FinancialTable columns={columns} data={data} density="comfortable" />
<FinancialTable columns={columns} data={data} density="spacious" />
{/* Striped rows */}
<FinancialTable columns={columns} data={data} striped />
</>
)
}Features
Built-in functionality
- Currency display: Show currency codes in column headers
- Number formatting: Locale-aware formatting with custom decimals
- Negative highlighting: Red text for negative values
- Column sorting: Click headers to sort ascending/descending
- Totals row: Automatic sum calculation for numeric columns
- Monospace numbers: Tabular nums for aligned columns
- Density options: Compact, comfortable, spacious row heights
- Dark mode: Full dark mode support
Accessibility
Accessibility considerations
ARIA Attributes
Uses semantic table elementsSortable columns have aria-sort attributeTotals row uses tfoot elementKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between sortable headers |
| Enter / Space | Toggle sort direction |
Notes
- Sort state announced to screen readers
- Negative values visually distinct (not relying on color alone)
- Currency values properly formatted for screen readers