ui/Datatable.svelte

Generic CSS-subgrid datatable. Sticky header, pointer-driven column resize, and optional header / cell / empty snippets for custom rendering. Default cell rendering uses column.format(value, row) if present, else format_value. Resize deltas are kept in component-local state, keyed by column.key — they don't outlive the component.

Rows are keyed by the required row_key accessor, so per-row state (popovers, pending buttons) follows its row across deletes and refetches. A row whose key is null or undefined throws in DEV.

Exposed as an ARIA table (not grid — there's no grid keyboard model): row / columnheader / cell roles, with the empty state a full-width row of its own.

view source

Declarations
#

Datatable
#

ui/Datatable.svelte view source

accepts children

import Datatable from '@fuzdev/fuz_app/ui/Datatable.svelte';

columns

type DatatableColumn<T>[]

rows

type T[]

row_key

The row's stable identity, used as the keyed-each key — e.g. (row) => row.id.

type (row: T) => PropertyKey
snippet parameters
row T

height?

CSS height for the scrollable region (e.g. '400px'). Omit to size to content.

type string
optional

header?

Override default header-cell rendering. Receives the column.

type Snippet<[column: DatatableColumn<T>]>
optional
snippet parameters
column DatatableColumn<T>

cell?

Override default cell rendering. Receives column, row, and the cell value.

type Snippet<[column: DatatableColumn<T>, row: T, value: T[keyof T]]>
optional
snippet parameters
column DatatableColumn<T>
row T
value T[keyof T]

empty?

Rendered when rows is empty. Defaults to a no data text.

type Snippet<[]>
optional

external types

SvelteHTMLElements['div']

generics

Datatable<T extends Record<string, any> = Record<string, any>>
T
constraint Record<string, any>
default Record<string, any>

Depends on
#

Imported by
#