ListPage
Complete list page rendered from a single CrudConfig — search, sort, pagination, dialogs
Complete list page component driven by a single CrudConfig — built-in search, sorting,
pagination, row/header actions, and CRUD dialogs.
ListPage takes a single config: CrudConfig<T, TFormData> prop: title, columns, data and
loading all live in config.
Basic Usage
Data loading, search, and mutations all come from config — built with React Query
(config.query.queryFn fetches from your REST API; config.mutations.* handle create/update/delete).
'use client'
import { type CrudConfig } from '@telamonjs/ui'
import { usersApi } from '@/lib/api/users-client'
export const config: CrudConfig<User, UserFormData> = {
module: { name: 'users', title: 'Users', description: 'Manage system users', route: '/admin/users' },
list: { title: 'Users', description: 'Registered users', columns, searchPlaceholder: 'Search by name or email...' },
form: { sections, validation: validationSchema },
// queryFn resolves PaginatedResponse<User> ({ data, total, page, totalPages })
query: { queryKey: ['users'], queryFn: usersApi.list },
mutations: {
// mutationFn resolves { success, data? } — shape it here, not in the API client
create: {
mutationFn: async (data) => ({ success: true, data: await usersApi.create(data) }),
invalidates: [['users']],
},
update: {
mutationFn: async ({ id, data }) => ({ success: true, data: await usersApi.update(id, data) }),
invalidates: [['users']],
},
delete: {
mutationFn: async ({ id }) => {
await usersApi.delete(id)
return { success: true }
},
invalidates: [['users']],
},
},
}import { ListPage } from '@telamonjs/ui'
import { config } from './config'
export default function UsersPage() {
return <ListPage config={config} />
}Props
Prop
Type
Use CrudConfigWithAnyForm<TData> (not as any) when a helper needs to accept a config with
any form-data shape — TFormData on CrudConfig is invariant.
Full interface (includes filters, bulk actions, toolbar slots)
interface ListPageProps<TData> {
config: CrudConfigWithAnyForm<TData>
tableId?: string
urlSync?: boolean
urlFilters?: Record<string, 'string' | 'number'>
cardComponent?: ComponentType<{ data: TData; onClick?: (data: TData) => void }>
className?: string
onRefreshAction?: () => Promise<void | { success: boolean }>
filterOptions?: ColumnFilterConfig
loadFilterOptions?: () => Promise<ColumnFilterConfig>
enableBulkActions?: boolean
bulkActions?: BulkAction<TData>[]
headerActions?: Array<{
label: string
icon?: ReactNode
onClick: () => void
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost'
loading?: boolean
}>
disableAutoRefresh?: boolean
errorBoundary?: boolean
errorFallback?: ReactNode
toolbarPrepend?: ReactNode
toolbarContent?: ReactNode | ((state: ListQueryState) => ReactNode)
filtersPanel?: ReactNode
activeFilters?: Array<{ key: string; label: string; onRemove: () => void }>
onClearFilters?: () => void
footerContent?: ReactNode
embedded?: boolean
dialogUrlSync?: boolean // default true
}Column Definitions
config.list.columns takes CrudColumnDef<T> — a TanStack Table column definition whose
header also accepts an I18nText:
import type { CrudColumnDef } from '@telamonjs/ui'
export const columns: CrudColumnDef<User>[] = [
{ accessorKey: 'name', header: 'Name' },
{ accessorKey: 'email', header: 'Email' },
{
accessorKey: 'role',
header: 'Role',
cell: ({ row }) => {
const role = row.original.role
return <Badge variant={role === 'ADMIN' ? 'default' : 'secondary'}>{role}</Badge>
},
},
{
accessorKey: 'createdAt',
header: 'Created At',
cell: ({ row }) => new Date(row.original.createdAt).toLocaleDateString(),
},
]Row and Header Actions
Row actions live in config.actionsConfig (DataTableActionsConfig); toolbar buttons are the
headerActions prop of ListPage:
export const config: CrudConfig<User, UserFormData> = {
// ...
actionsConfig: {
custom: [
{ id: 'open-page', label: 'Open page', href: row => `/admin/users/${row.id}` },
{ id: 'reset', label: 'Reset password', onClick: row => resetPassword(row.id), variant: 'destructive' },
],
},
}<ListPage
config={config}
headerActions={[{ label: 'Import', onClick: handleImport, variant: 'outline' }]}
/>create/update/delete row and header actions (edit/view/create dialogs) are wired
automatically from config.dialogs and config.mutations — see the
Dialog Pattern and
ListPage Pattern for the full dialog configuration.
Embedded (Dashboard Tabs)
Inside a tabbed dashboard (ShellPage + AdminHeader + AdminTabs), render the list with
embedded to drop the outer page chrome:
<ListPage config={config} embedded />Features
Built-in:
- ✅ Pagination (client or server-side, driven by
config.query) - ✅ Search (debounced)
- ✅ Sorting (click column headers;
list.sortParampicks whatsortBycarries) - ✅ Filtering (column filters and
list.toolbar.filters) - ✅ Row actions (contextual menu) and header actions (toolbar buttons)
- ✅ Create/edit/view/delete dialogs from
config.dialogs+config.mutations - ✅ Mobile-responsive (switches to cards)
- ✅ Loading, empty, and error states
- ✅ Excel/CSV/PDF export (
list.enableExport): the loaded rows, every matching row (list.exportAll) or your backend (list.onExport) — see exporting every row
Best Practices
- Keep
columns,sections,validation,query, andmutationstogether in oneconfig.tsx(Page Config Pattern) - Use
queryKey/invalidatesconsistently so mutations refresh the right list - Provide
searchPlaceholderfor better UX - Use
embeddedinsideAdminTabs, not a standalone page per module
Related Components
- DataTable - Lower-level table (more customization)
- MobileCard - Card component for mobile view
See Also
- ListPage Pattern - Best practices, dialogs
- Module Structure - Fetch/mutate via CrudConfig