NuGrid includes a built-in compact theme optimized for displaying dense data like financial dashboards and analytics tools.
Apply the compact theme with the theme prop:
<template>
<NuGrid
theme="compact"
:data="data"
:columns="columns"
/>
</template>
| Feature | Default Theme | Compact Theme |
|---|---|---|
| Cell padding | 16px | 8px |
| Font size | Normal | Slightly smaller |
| Row height | ~48px | ~32px |
| Accent color | App primary | Blue (#2196F3) |
| Header style | Standard | Uppercase, gray bg |
<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>
The compact theme is ideal for: