100
Total Employees
Β£77,080
Average Salary
7
Departments

Component Comparison

DataGridBasic

  • βœ“ Zero dependencies
  • βœ“ Copy-paste ready
  • βœ“ ~10KB bundle size
  • βœ“ Column sorting
  • βœ“ Global search
  • βœ“ Pagination
  • βœ— No virtual scrolling
  • βœ— No inline editing
  • βœ— Basic filtering only

Best for: Small-medium datasets (up to 500 rows), prototypes, learning

DataGridAdvanced

  • βœ“ Virtual scrolling
  • βœ“ Global search
  • βœ“ Column sorting
  • βœ“ Inline editing
  • βœ“ Row selection
  • βœ“ Bulk operations
  • βœ“ CSV export
  • βœ“ Theme support
  • βœ— Requires SVAR Grid
  • βœ— ~155KB bundle
  • βœ— Not copy-paste ready

Best for: Large datasets (1000s of rows), production apps, rich features

Live Examples

Currency Format Comparison - Choose Your Format

The same salary data displayed in three different formats. You choose which formatter to use for each column!

Three Currency Formatters Available:

  • formatCurrency - Standard with commas, no decimals (e.g., Β£75,000)
  • formatCurrencyDecimals - With commas AND decimals (e.g., Β£75,000.00)
  • formatCurrencyCompact - With K/M abbreviations (e.g., Β£75K)

Each column below uses a different formatter on the same salary data. You can use different formats in different columns based on your needs!

First Name Last Name Standard (No Decimals) With Decimals Compact (K/M)
GraceAllenΒ£62,000Β£62,000.00Β£62K
LauraAndersonΒ£70,000Β£70,000.00Β£70K
MayaAngelouΒ£66,000Β£66,000.00Β£66K
NeilArmstrongΒ£105,000Β£105,000.00Β£105K
EveArnoldΒ£80,000Β£80,000.00Β£80K
FelixBaumgartnerΒ£73,000Β£73,000.00Β£73K
XanderBerkeleyΒ£73,000Β£73,000.00Β£73K
ZachBraffΒ£75,000Β£75,000.00Β£75K
EmilyBrownΒ£72,000Β£72,000.00Β£72K
UrsulaBurnsΒ£80,000Β£80,000.00Β£80K
Showing 1–10 of 100

How to Use Different Formatters:

import { formatCurrency, formatCurrencyDecimals, formatCurrencyCompact } from '$lib/dataGridFormatters';

const columns: DataGridColumn[] = [
  {
    id: 'annualBudget',
    header: 'Annual Budget',
    formatter: formatCurrencyCompact  // ← Use compact for large numbers (Β£1.5M)
  },
  {
    id: 'productPrice',
    header: 'Product Price',
    formatter: formatCurrencyDecimals  // ← Use decimals for precise prices (Β£12.99)
  },
  {
    id: 'totalRevenue',
    header: 'Total Revenue',
    formatter: formatCurrency  // ← Use standard for whole numbers (Β£75,000)
  }
];

Usage Guide

Column Styling & Formatting

<script>
  import DataGridBasic from '$lib/components/DataGridBasic.svelte';
  import {
    formatCurrencyCompact,
    createGradientStyle,
    createStatusBadge,
    createIconRenderer
  } from '$lib/dataGridFormatters';

  const columns = [
    {
      id: 'salary',
      header: 'Salary',
      type: 'number',
      formatter: formatCurrencyCompact, // Β£75K, Β£1.5M
      cellStyle: createGradientStyle(30000, 150000, '#ef4444', '#22c55e')
    },
    {
      id: 'status',
      header: 'Status',
      cellRenderer: createStatusBadge({
        'active': { color: '#22c55e', label: 'Active' },
        'on-leave': { color: '#f59e0b', label: 'On Leave' }
      })
    },
    {
      id: 'performance',
      header: 'Level',
      cellRenderer: createIconRenderer([
        { max: 50000, icon: 'πŸ“‰', color: '#ef4444' },
        { max: 100000, icon: 'πŸ“Š', color: '#3b82f6' },
        { max: Infinity, icon: 'πŸ“ˆ', color: '#22c55e' }
      ])
    }
  ];
</script>

<DataGridBasic { data } { columns } />

DataGridBasic - Copy & Paste Ready

<script>
  import DataGridBasic from '$lib/components/DataGridBasic.svelte';

  const columns = [
    { id: 'name', header: 'Name', width: 150 },
    { id: 'email', header: 'Email', type: 'email' },
    {
      id: 'salary',
      header: 'Salary',
      type: 'number',
      formatter: (val) => `Β£${val.toLocaleString()}`
    }
  ];

  const data = [
    { name: 'John Doe', email: 'john@example.com', salary: 75000 },
    // ... more rows
  ];
</script>

<DataGridBasic
  { data }
  { columns }
  sortable={ true }
  filterable={ true }
  pageSize={ 10 }
/>

DataGridAdvanced - Production Features

<script>
  import DataGridAdvanced from '$lib/components/DataGridAdvanced.svelte';

  // Auto-generates columns from data structure
  const employees = []; // Your employee data
</script>

<DataGridAdvanced
  data={ employees }
  editable={ true }
  selectable={ true }
  exportable={ true }
  pageSize={ 20 }
  theme="willow"
/>

DataGridFilters - Advanced Filtering

<script>
  import DataGridFilters from '$lib/components/DataGridFilters.svelte';
  import DataGridAdvanced from '$lib/components/DataGridAdvanced.svelte';

  let filters = $state({
    departments: [],
    statuses: [],
    salaryMin: 30000,
    salaryMax: 150000,
    hireDateFrom: '',
    hireDateTo: ''
  });

  const filteredData = $derived.by(() => {
    return data.filter(employee => {
      // Apply filter logic
      return true;
    });
  });
</script>

<DataGridFilters
  departments={ ['Engineering', 'Sales', 'Marketing'] }
  statuses={ ['active', 'on-leave'] }
  salaryRange={ { min: 30000, max: 150000 } }
  onFiltersChange={ (newFilters) => filters = newFilters }
/>

<DataGridAdvanced
  data={ filteredData }
  editable={ false }
  selectable={ false }
  pageSize={ 20 }
  exportable={ true }
/>

Department Breakdown

Engineering
31 employees
Sales
19 employees
Marketing
14 employees
Design
12 employees
Finance
10 employees
Customer Success
7 employees
HR
7 employees