DocsBlog
  • 1.1.2

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Data Grid
Signals
Styling
Theming

Get Started

OverviewQuick StartColumnsContextThemeNew

Layout

DimensionsSizingSlotsToolbarFooterNewPagination

Features

PinningSorting

Reference

API

On this page

  • Edit this page on Github

Footer

Learn how to create custom footers in the Data Grid component.

  • source

Overview

The Footer is a reserved area below the Data Grid component typically used for information or global actions.

To add a custom footer, you can use the footer prop and pass a React component.

Since the footer is positioned within the Data Grid component, it shares the same height restrictions as the grid itself. Ensure your parent height is set appropriately to accommodate the footer.

Note

If you don't need the context of the grid, we recommended rendering your footer outside of the Data Grid component.

Grid Context

To access the Data Grid context, you use the useDataGridContext hook which provides a signal driven store for reading and updating state in a highly performant way.

Read the Data Grid Context documentation for more details.

Copy
'use client'

import { DataGrid, useDataGridContext } from '@cerberus/data-grid'
import { useRead } from '@cerberus/signals'
import { HStack, Stack } from 'styled-system/jsx'
import { columns } from '../quick-start/columns.demo'
import { createFakeQuery } from '../quick-start/data'
import { type Employee } from '../quick-start/data.demo'

export function FooterDemo() {
  // Normally this would be from useQuery or a server-side API call
  const data = createFakeQuery(200)

  return (
    <Stack direction="column" gap="md" h="25rem" mb="md" w="90%">
      <DataGrid columns={columns} data={data()} footer={<Footer />} />
    </Stack>
  )
}

function Footer() {
  const store = useDataGridContext<Employee>()
  const totalCount = useRead(store.rowCount)
  return <HStack w="full">This table has {totalCount} rows</HStack>
}
This table has 200 rows