Skip to main content

ListShell

A list with the arrangement the generated lists use: the datagrid in a paper card, inline filters above it, and the filter / column / sort buttons in its toolbar.

Use it for a list you assemble by hand — a report table, a picker screen. For a resource's own list, SchemaList does this and reads the schema too.

Example​

import {ListShell, SearchInput, ChoicesInput} from 'habarico';

const SORT = {field: 'placed_at', order: 'DESC'} as const;

<ListShell
resource="eshop/order"
title="Orders"
listConfig={{
preferenceKey: 'eshop/order.list',
sort: SORT,
filterDefaultValues: {},
filters: [<ChoicesInput key="status" source="status" choices={statusChoices} />],
}}
controllerProps={{sort: SORT, perPage: 25}}
filters={<SearchInput source="q" alwaysOn />}
toolbarActions={<CreateButton />}
>
<OrderDatagrid />
</ListShell>

Props​

NameTypeDefaultDescription
children (required)ReactNode—The datagrid
listConfig (required)ListConfig—Feeds ListConfigContext; four of its keys are required — see below
resourcestringresource from contextWraps the list in a ResourceContextProvider; omit when an ambient resource exists
controllerPropsOmit<ListProps, 'children'>—Plain React Admin <List> props — sort, perPage, filter, filterDefaultValues, queryOptions, exporter, pagination, empty, …
infinitebooleanfalseUses <InfiniteList> and appends an <InfinitePagination> instead of paging
titleReactNode—Portaled to the layout header
breadcrumbsReactNode—Injected into the layout's breadcrumb slot
toolbarActionsReactNode—Portaled next to the title
listActionsReactNodeDatagridActionsThe datagrid toolbar — filter drawer, column selector, filter, sort and config resets. null hides it
filtersReactElement—The inline filter node rendered above the datagrid
sidePanelReactNode—A docked detail panel; the body becomes a two-column layout

ListConfig​

The datagrid's configuration buttons — the filter drawer, the column selector, the filter, sort and config resets — read their state from this object, so the first four keys have to be there:

KeyTypeWhat reads it
preferenceKeystringWhere the column selection, widths and saved queries are stored per user
sortSortPayloadThe "reset sort" button, to know what to reset to
filterDefaultValuesobjectThe "reset filters" button (in the ⋮ menu and the filter drawer's footer) and the "reset table settings" button
filtersReactElement<InputProps>[]The inputs the filter drawer renders
hasInlineFiltersbooleanWhether the list also has inline filters; the "reset filters" button is offered when this is true or filters is not empty. Optional — the shell defaults it to whether the filters prop is passed
caution

listConfig.filters and the filters prop are two different slots: the prop is the inline filter node above the table, listConfig.filters is the array the drawer builds itself from. The generated list splits one filter set between them by isAlwaysOn.

The card around the datagrid is ListSurface and is owned by this shell — a list is the one view type with an outer paper surface. ListSurface is exported on its own ({children, sidePanel}) for the rare case where you want the card without the controller.

See also​