Theming

Compact Theme

Dense layout for data-heavy applications.

NuGrid includes a built-in compact theme optimized for displaying dense data like financial dashboards and analytics tools.

Interactive Demo

Basic Usage

Apply the compact theme with the theme prop:

<template>
  <NuGrid
    theme="compact"
    :data="data"
    :columns="columns"
  />
</template>

Theme Comparison

FeatureDefault ThemeCompact Theme
Cell padding16px8px
Font sizeNormalSlightly smaller
Row height~48px~32px
Accent colorApp primaryBlue (#2196F3)
Header styleStandardUppercase, gray bg

Complete Example

<script setup lang="ts">
import type { NuGridColumn } from '#nu-grid/types'

interface StockData {
  symbol: string
  company: string
  price: number
  change: number
  volume: number
}

const data = ref<StockData[]>([
  { symbol: 'AAPL', company: 'Apple Inc.', price: 178.42, change: 2.34, volume: 52847123 },
  { symbol: 'MSFT', company: 'Microsoft', price: 378.91, change: -1.23, volume: 21456789 },
  { symbol: 'GOOGL', company: 'Alphabet', price: 141.80, change: 0.87, volume: 18923456 },
  // ... more data
])

const columns: NuGridColumn<StockData>[] = [
  { accessorKey: 'symbol', header: 'Symbol', size: 80 },
  { accessorKey: 'company', header: 'Company', size: 150 },
  {
    accessorKey: 'price',
    header: 'Price',
    size: 90,
    cell: ({ row }) => `$${row.original.price.toFixed(2)}`,
  },
  {
    accessorKey: 'change',
    header: 'Change',
    size: 80,
    cell: ({ row }) => {
      const change = row.original.change
      const color = change >= 0 ? 'text-green-500' : 'text-red-500'
      const sign = change >= 0 ? '+' : ''
      return h('span', { class: color }, `${sign}${change.toFixed(2)}`)
    },
  },
  {
    accessorKey: 'volume',
    header: 'Volume',
    size: 100,
    cell: ({ row }) => row.original.volume.toLocaleString(),
  },
]
</script>

<template>
  <NuGrid
    theme="compact"
    :data="data"
    :columns="columns"
    :focus="{ mode: 'cell' }"
    selection="multi"
    resize-columns
  />
</template>

When to Use Compact Theme

The compact theme is ideal for:

  • Financial dashboards - Stock tickers, trading interfaces
  • Analytics tools - Data tables with many columns
  • Admin panels - Dense data management interfaces
  • Log viewers - Displaying many rows of data
The compact theme supports full dark mode. Colors automatically adjust based on your app's color scheme.